Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Define first row imported from XLS
Message
From
07/07/1999 08:23:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/07/1999 06:00:43
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00237650
Message ID:
00238192
Views:
12
>>More explanation pls. Blindly clue commands :
>>with oExcel.ActiveSheet.Cells(nRow.nCol).CurrentRegion
>>lnColumns = .Columns.count
>>lnRows = .Rows.Count
>>
>>oRange.Offset(nRow, nCol)
>>Cetin
>
>Cetin,
>
>Thanks already the Currentregion is pointing into the right direction but isn't bulletproof.
>Let's say you have an excel sheet with the first five rows who are blank.
>Than the following rows contain the data to import.
>Now using the IMPORT FROM XLS in Foxpro imports the excel sheet into a DBF with the same name. But what you see is that the first five rows of the excel sheet aren't in the imported DBF. The first record of the imported excel sheet is the data from the 6th row in the excel sheet.
>Hope this clears out more what I am looking for. Hope you have any more ideas.
>
>TIA.
Yves,
Excel data is imported from header row + nonempty rows. To achieve what you want I would move the header row to row 1, fill empty rows first column with a dummy value (so it's included in import) and saveas. If the first row is not a header row record then drop moving to row 1 part but do fill empty rows with a dummy value. ie:
* Need xlConstants.h or explicitly define used xl* constants
#include "xlConstants.h"

USE home()+"samples\data\customer"
Application.datatoclip("customer",reccount(),3)
oExcel = createobject("Excel.application")
WITH oExcel
  .WorkBooks.Add
  WITH .ActiveSheet
    .Range("D9").select
    .Paste
    .Range("A1").select
    .Range("A1").SpecialCells(xlLastCell).CurrentRegion.Select

    lcStartRow = .Application.selection.rows(1).Address(.f.,.f.,xlA1) && D9:P9
    lnStartRow = val(substr(lcStartRow,2))  && 9
    lcNewRow = strtran(lcStartRow, ltrim(str(lnStartRow)), "1") && D1:P1
    lcNextRow = strtran(lcStartRow, ltrim(str(lnStartRow)), "2") && D2:P2
    lcFillRange = substr(lcNextRow,1, at(":",lcNextRow) ) + ;
      substr(lcStartRow, 1, at(":",lcNextRow)-1 )

    .Range(lcStartRow).cut
    .Range(lcNewRow).select
    .Paste && Moved header to row 1
    .Range(lcFillRange).value = "-"  && Fill dummy "-" so included in import
    .SaveAs("c:\temp\myimport.xls",xlExcel5)
  ENDWITH
  .WorkBooks(1).saved = .t.
  .quit
  *	.visible = .t.
ENDWITH
IMPORT from ("c:\temp\myimport.xls") type xl5
BROW
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform