XLSX-Workbook-Class icon indicating copy to clipboard operation
XLSX-Workbook-Class copied to clipboard

feature request / SaveTablesToWorkBook

Open lscheffler opened this issue 3 years ago • 2 comments

SaveTablesToWorkBook and SaveTablesToWorkBookEx do a great job. Except I can not adress the location. It will create a new sheet and start on A1. What I like would the possibility to (optionally) address:

  • an existing sheet
  • a starting cell for header
  • a starting cell for data
    The calling code must be responsible to place the stuff on something meaningful, so data should not write over header line.

Parameters like:

LPARAMETERS tcAlias, tnWB, tlFreeze, tlSaveWB,;
tvSheet, toHeaderLoc, toDataLoc

where

tvSheet

Type Char

as existing tcSheetName

Type Num

number (Id) of existing sheet to write to

Locs

toHeaderLoc and toDataLoc could be an empty object like

  • toHeaderLoc.BegCol
  • toHeaderLoc.BegRow

toHeaderLoc and toDataLoc are used for tvSheet as number only, only for existing tnWB too.


In this way I could fill data into an existing workbook / template and should be able to keep existing formats etc. As far as I see the write would work with existing sheets/cells.

lscheffler avatar May 15 '21 14:05 lscheffler

Will look into adding this feature request. The SaveTablesToWorkBookEx() method is designed to write directly to a new spreadsheet file; so there is not an existing sheet to write to. Method SaveTablesToWorkBook() could be enhanced to selectively create a new sheet or write to an existing sheet. Both methods could have optional parameters for the starting column and row. However, the checking of existing data in the cells would add considerable overhead and then what to do if found? So I don't think this would be feasible.

ggreen86 avatar Jul 13 '21 15:07 ggreen86

Sorry for the delay. First full of work, then vacation. :D
What I like to have for SaveTablesToWorkBook:

  • a way to address a sheet different then sheet number 1 - this is tvSheet Running number or sheet name. The calling code is responsible to create / name sheets if needed.
  • only write the data to the cells, this is
    • create cells if not existing
    • fill existing cells with data, but do not touch existing formats

I understand this is slower then just putting the data into an empty sheet. But it's still faster the using EXCEL automation for it. If EXCEL is available at all, what is a problem with the cloud based stuff. So for the speed it is a minor issue.

Sure, it could be an additional method, what keeps SaveTablesToWorkBook as simple and fast.

lscheffler avatar Aug 27 '21 16:08 lscheffler