Page 1 of 1

Add new sheet

Posted: Mon Apr 08, 2013 7:46 am
by odisej
Hi all

I'm using TXLSSpreadSheet and I'd like to add a sheet into workbook. What I do is this:

Code: Select all

  with XLSBook.XLS.Sheets.Add() do
  begin
    DisplayName := 'my sheet';
    Visible := true;
  end;
  //what goes here !!!!
What I need to call on TXLSSpreadSheet so it will be refreshed. Invalidate doesn't work. If I save the TXLSReadWriteII4 and reopen it, I can see new sheet although it has default name 'Sheet2', I expected name to be 'my sheet'.

Re: Add new sheet

Posted: Mon Apr 08, 2013 8:05 am
by odisej
Same question goes for borders. I'm using the code below and I must reopen xls to see some changes.

Code: Select all

    XLSBook.XLSSheet.Range.Items[a.Col1, a.Row1, a.Col2, a.Row2].BorderLeftStyle := cbsThin;
    XLSBook.XLSSheet.Range.Items[a.Col1, a.Row1, a.Col2, a.Row2].BorderTopStyle := cbsThin;
    XLSBook.XLSSheet.Range.Items[a.Col1, a.Row1, a.Col2, a.Row2].BorderRightStyle := cbsThin;
    XLSBook.XLSSheet.Range.Items[a.Col1, a.Row1, a.Col2, a.Row2].BorderBottomStyle := cbsThin;
    XLSBook.XLSSheet.Range.Items[a.Col1, a.Row1, a.Col2, a.Row2].BorderInsideVertStyle := cbsThin;
    XLSBook.XLSSheet.Range.Items[a.Col1, a.Row1, a.Col2, a.Row2].BorderInsideHorizStyle := cbsThin;
    XLSBook.Invalidate; //doesn't work

Re: Add new sheet

Posted: Mon Apr 08, 2013 8:34 am
by larsa
Hello

1. After adding new sheets, use: XLSBook.Int_InvalidateSheet;

2. Use XLSBook.InvalidateSheet(Sheet);

Re: Add new sheet

Posted: Mon Apr 08, 2013 8:43 am
by odisej
larsa wrote:Hello

1. After adding new sheets, use: XLSBook.Int_InvalidateSheet;

2. Use XLSBook.InvalidateSheet(Sheet);
Great. Thanks.

Re: Add new sheet

Posted: Tue Feb 11, 2014 9:13 pm
by flls
In the current version of TXLSSpreadSheet there is no more "InvalidateSheet (Sheet)" method, it was replaced by "InvalidateSheet ()" method (without parameters).

The problem is that this method is not drawing new worksheets. How do I draw them now?

TXSLReadWriteII V5.20.15a
TXLSSpreadSheet V2.00.02

Re: Add new sheet

Posted: Thu Feb 13, 2014 9:14 am
by larsa
Hello

This is fixed in the latest update, 2.00.05

Re: Add new sheet

Posted: Fri Feb 28, 2014 12:34 pm
by flls
I installed version 2.00.5 but nothing has changed, still without drawing new sheets in TXLSSpreadSheet component.

Although not view the sheets in the component when the spreadsheet is saved to disk and open in the Excel sheets are displayed correctly, then the problem is with the TXLSSpreadSheet component and not with XLSReadWrite.

I am creating the sheets as follows:

Plan.XLS.Add.Name := SheetName;
Plan.InvalidateSheet;


PS: Just to be clear: The component must be correctly drawing the sheets, the problem is with the navigation bar at the bottom of the worksheet is not updated, and always displays a single tab named Sheet1.

Re: Add new sheet

Posted: Mon Jan 27, 2020 11:25 am
by Hans Toni Ratte
Does the latest Version in between allow copying Areas from one sheet to another one (including also cell formats)?

Re: Add new sheet

Posted: Mon Jan 27, 2020 2:39 pm
by larsa
Hello

Please don't reply to several years old threads.

Use XLS.CopyCells for copying cells between sheets, with or without formatting.