Add new sheet

Questions and answers on how to use XLSSpreadSheet.
Post Reply
odisej
Posts: 34
Joined: Mon Apr 08, 2013 7:42 am

Add new sheet

Post 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'.
odisej
Posts: 34
Joined: Mon Apr 08, 2013 7:42 am

Re: Add new sheet

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Add new sheet

Post by larsa »

Hello

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

2. Use XLSBook.InvalidateSheet(Sheet);
Lars Arvidsson, Axolot Data
odisej
Posts: 34
Joined: Mon Apr 08, 2013 7:42 am

Re: Add new sheet

Post by odisej »

larsa wrote:Hello

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

2. Use XLSBook.InvalidateSheet(Sheet);
Great. Thanks.
flls
Posts: 13
Joined: Fri Feb 07, 2014 8:58 pm

Re: Add new sheet

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Add new sheet

Post by larsa »

Hello

This is fixed in the latest update, 2.00.05
Lars Arvidsson, Axolot Data
flls
Posts: 13
Joined: Fri Feb 07, 2014 8:58 pm

Re: Add new sheet

Post 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.
Hans Toni Ratte
Posts: 3
Joined: Thu Jan 16, 2020 2:44 pm

Re: Add new sheet

Post by Hans Toni Ratte »

Does the latest Version in between allow copying Areas from one sheet to another one (including also cell formats)?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Add new sheet

Post by larsa »

Hello

Please don't reply to several years old threads.

Use XLS.CopyCells for copying cells between sheets, with or without formatting.
Lars Arvidsson, Axolot Data
Post Reply