Quantcast
Channel: VFPX
Viewing all articles
Browse latest Browse all 3798

New Comment on "XLSXWorkbook"

$
0
0
Hi Greg. I have some other suggestions: 1. If you have a sheet named "Test1" and want to add a sheet named "Test", the SEEK in AddSheet can find the Test1 record if EXACT is set off. I changed it to this: *** DH 2016-06-30: use PADR on seek so no partial name match ***IF SEEK(BINTOC(tnWB), "c_workbooks", "workbook") .AND. !SEEK(BINTOC(tnWB)+UPPER(tcSheetName), "c_sheets", "shname") IF SEEK(BINTOC(tnWB), "c_workbooks", "workbook") .AND. !SEEK(BINTOC(tnWB)+UPPER(padr(tcSheetName, len(c_sheets.shname))), "c_sheets", "shname") 2. SaveTableToWorkbook: accept an optional tcSheetName parameter: *** DH 2016-06-30: accept optional tcSheetName parameter ***LPARAMETERS tcAlias, tcWBName, tlFreeze, tlSaveWB LPARAMETERS tcAlias, tcWBName, tlFreeze, tlSaveWB, tcSheetName Use the parameter if passed: *** DH 2016-06-30: use either the alias or tcSheetName as the sheet name *** lnSh = this.AddSheet(lnWB, lcAlias) local lcSheetName if vartype(tcSheetName) = 'C' and not empty(tcSheetName) lcSheetName = tcSheetName else lcSheetName = lcAlias endif vartype(tcSheetName) = 'C' ... lnSh = this.AddSheet(lnWB, lcSheetName) *** DH 2016-06-30: end of new code 3. Same with SaveGridToWorkbook: *** DH 2016-06-30: accept optional tcSheetName parameter ***LPARAMETERS toGrid, tcWBName, tlFreeze, tlSaveWB LPARAMETERS toGrid, tcWBName, tlFreeze, tlSaveWB, tcSheetName Use the parameter if passed: *** DH 2016-06-30: use either the workbook name or tcSheetName as the sheet name *** lnSh = this.AddSheet(lnWB, JUSTSTEM(tcWBName)) local lcSheetName if vartype(tcSheetName) = 'C' and not empty(tcSheetName) lcSheetName = tcSheetName else lcSheetName = JUSTSTEM(tcWBName) endif vartype(tcSheetName) = 'C' ... lnSh = this.AddSheet(lnWB, lcSheetName) *** DH 2016-06-30: end of new code 4. Have SaveGridToWorkbook call GetWorkbook if CreateWorkbook returns 0 like SaveTableToWorkbook does: lnWB = this.CreateWorkbook(tcWBName) *** DH 2016-06-30: if workbook exists, get reference to it IF lnWB = 0 lnWB = this.GetWorkbook(tcWBName) ENDIF *** DH 2016-06-30: end of new code 5. Both SaveTableToWorkbook and SaveGridToWorkbook call CreateWorkingCursors which prevents them from adding a new sheet to an existing workbook if OpenXLSWorkbook is called first. I commented out the code calling CreateWorkingCursors and DestroyWorkingCursors in both methods since they aren't needed (Init creates the cursors): *** DH 2016-06-30: don't call CreateWorkingCursors: they're already open and that prevents *** calling OpenXlsxWorkbook first to append to existing workbook ***this.AllowChangeDE = False ***IF this.UsePrivateDE *** this.CreateWorkingCursors() ***ENDIF and: *** DH 2016-06-30: don't call DestroyWorkingCursors. ***IF this.UsePrivateDE *** this.DestroyWorkingCursors() ***ENDIF 6. If the grid HeaderHeight is 0, don't output column headers in SaveGridToWorkbook: FOR lnCol=1 TO toGrid.ColumnCount *** DH 2016-06-30: added next line so only output headings if HeaderHeight > 0 if toGrid.HeaderHeight > 0 this.SetCellValue(lnWB, lnSh, lnRow, lnCol, toGrid.Columns(lnCol).Header1.Caption) *** DH 2016-06-30: added ENDIF endif toGrid.HeaderHeight > 0 this.SetColumnWidth(lnWB, lnSh, lnCol, this.ConvertPixelsToExcelUnits(toGrid.Columns(lnCol).Width)) ENDFOR *** DH 2016-06-30: if no headers, start in first row if toGrid.HeaderHeight = 0 lnRow = 0 endif toGrid.HeaderHeight = 0 *** DH 2016-06-30: end of new code Doug

Viewing all articles
Browse latest Browse all 3798

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>