Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Greg Green XLSXWorkBookVFPX for extracting from Ex
Message
From
30/11/2018 13:49:25
 
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
01663900
Message ID:
01663940
Views:
58
Dmitry--

"thisform.Workbook" in my code is an instance of the excel class (the below code snippet was from a form that I have) and should be loExcel to be consistent in the example below. Sorry for the confusion. The parameter tnWB is a return value from the method OpenXlsxWorkbook() as shown below. You can have multiple workbooks open in the class. To get multiple sheets, use the method GetWorkbookSheets() -- it returns an object that has properties 'Count' and 'List[]' (see documentation for more).

>Hi Greg,
>Thank you for your reply.
>What is the value of "thisform.Workbook" in your sample code? The docs show the first parameter of the GetSheetRowValues as tnWB. How do I determine it? I tried to pass the name but I get an error.
>
>TIA
>
>
>>Hello--
>>
>>Glad you are trying to use the class -- hopefully it will work for you needs. The class reads an XLSX file and loads the rows/cells into a cursor xl_cells (and others as well) as the main cursor that contains the sheet data. This table is documented in the documentation at the end.
>>
>>The basic steps are as follows (assuming you have the file name and have an instance of the class named loExcel); the below example only returns the first row in the sheet, just iterate over all rows to get all cell values.
>>
>>
>>
>>>nWB = loExcel.OpenXlsxWorkbook(lcFileName, .F.) && this opens the Excel file and reads into the internal cursors; lnWB is the handle to the new workbook
>>IF lnWB > 0
>> loRow = loExcel.GetSheetRowValues(thisform.Workbook, 1, 1) && See documentation -- this returns the cell values for first row with datatype
>> IF ISNULL(loRow)
>> && failure
>> ELSE
>> FOR lnCol=1 TO loRow.Count
>> IF !ISNULL(loRow.Values[lnCol, 1]) .AND. !EMPTY(loRow.Values[lnCol, 1])
>> && Got a cell value
>> ENDIF
>> ENDFOR
>> ENDIF
>>ELSE
>> && Failure
>>ENDIF
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform