Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VfpxWorkBookXlsx by Greg Green
Message
 
 
To
30/08/2018 15:00:56
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
01661763
Message ID:
01661790
Views:
80
>>Question.
>>I use method SaveTabletoWorkbook() to convert an open cursor to the Excel spreadsheet. I checked the return object for values (loReturn.sheet and loReturn.Workbook) and they both are 0 (zero). So, I assume that that method SaveTabletoWorkbook() closes the file. Therefore, in order for me to apply WordWrap to some cells, I need to re-open the file and the the handles for the method SetCellWordWrap(). How do you open an excel file and get the Id to workbook and Id to sheet in workbook?
>>
>>UPDATE: I do see in the docs the method OpenXlsxWorkbook() which returns Id for workbook. I also find the method GetWorkbookSheets() which should return the Id to the work book. I will try these.
>>
>>UPDATE2: The method OpenXlsxWorkbook() returns 0 (zero). This is how I call it:
>>
>>nId = loExcel.OpenXlsxWorkbook( cExcelFileName ) && the cExcelFileName includes the path to the existing file
>>
>>What am I doing wrong here?
>>
>When you use the method SaveTabletoWorkbook() it will save the table into the internal cursors and then save the table to a workbook. Pass the value .F. (false) for the fourth parameter to cause the method to not save the workbook. This will load the table into cursors only. The return value is an object with two properties:
>
>loReturn.Sheet = lnSh && sheet Id
>loReturn.Workbook = lnWB && workbook Id
>
>You can then use these two properties to then assign a style to the cells (word-wrap, font, etc.). There are methods to return the number of rows and max column. You will then need to save the workbook with the method SaveWorkbook(loReturn.Workbook) or the method SaveWorkbookAs(loReturn.Workbook, "c:\My file path\my workbook name.xlsx").
>
>>
>>Comment
>>It would nice (I know, just wishful thinking :)) if the method SaveTabletoWorkbook() would accept another parameter (optional), array or an object. And in this "array", the developer could define the styles for each column in the Excel( e.g. WordWrap). This way, the method SaveTabletoWorkbook() would use this "array" and apply the styles just as it creates the spreadsheet.
>
>This would be quite complicated to do. There are many formatting options for cells - font, size, color (background & foreground), border, etc.) and trying allow for all would be too much. The above approach allows the programmer to decide the formatting. Create the style and then apply to the cells.

Thank you for your reply and for instructions.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform