I have a TWebXLSX on my form. I use it to save various data as XLSX and have the need to clear the content before reusing the TWebXLSX.
I looked for a method TWebXLSX.clear but failed.
How can I clear the content of a TWebXLSX?
tx Bernd
I have a TWebXLSX on my form. I use it to save various data as XLSX and have the need to clear the content before reusing the TWebXLSX.
I looked for a method TWebXLSX.clear but failed.
How can I clear the content of a TWebXLSX?
tx Bernd
Hi,
It looks like the library itself doesn't come with a method to clear the contents.
Are you looking for something that removes all the sheets?
Or should it keep the sheets and remove the data only?
I want to "reset" the component. Clearing data, of course, but if I added sheets, they must be removed, too.
Workaround: Free/Create, I suppose?
That is one workaround, but you could also remove all sheets manually:
procedure TForm1.WebButton2Click(Sender: TObject);
var
I: Integer;
begin
for I := WebXLSX1.SheetNameCount - 1 downto 0 do
WebXLSX1.RemoveSheet(WebXLSX1.SheetNames[I]);
end;
We can put this behind a RemoveAllSheets
method for the next version.
This is good, but not exactly, what I wanted. I wanted a method to reset the component to the state it had after creation/being dripped on the form. So I suppose, one default sheet is created.
Do you encounter problems with adding an empty sheet? Normally this should produce the same output you are after:
procedure TForm1.WebButton1Click(Sender: TObject);
begin
WebXLSX1.RemoveAllSheets;
WebXLSX1.AddNewSheet;
end;
No problem at all. Just a matter of lazyness. :- )
I´d prefer:
procedure TForm1.WebButton1Click(Sender: TObject);
begin
WebXLSX1.Clear;
end;
Which in turn may be implemented:
procedureTWebXLSX.Clear;
begin
RemoveAllSheets;
AddNewSheet;
end;
We'll look to add this for the next version.