CopySheet and delete sheet do not adjust defined cell names

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
huseyinxy
Posts: 13
Joined: Wed Oct 07, 2015 7:41 am

CopySheet and delete sheet do not adjust defined cell names

Post by huseyinxy »

Hello,

I want copy one sheet including defined a cell name to new sheet and when i delete the first sheet defined cell name is being invalid, not refereced the new sheet.

CopySheet do not adjust the new defined name

Defined simple cell Name like this name: c_one reference: =Sheet1!$C$1

Same code with TXlsReadWriteII works correct but not work in TXlsReadWriteII5


my test code

Code: Select all

procedure TForm.Button1Click(Sender: TObject);
var
  fn1, fn2: string;
  Excel: TXlsReadWriteII5;
begin
  fn1 := 'D:\Tests\Excel\temp1.xls';
  fn2 := 'D:\Tests\Excel\temp2.xls';

  Excel := TXLSReadWriteII5.Create(nil);
  Excel.Filename := fn1;
  Excel.Read;


  // add new sheet and copy first one
  Excel.Add;
  Excel.CopySheet(0, 1);


  // delete first one
  Excel.Delete(0);


  Excel.SaveToFile(fn2);
  Excel.Free;
end;


larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: CopySheet and delete sheet do not adjust defined cell names

Post by larsa »

Hello

If the name is on sheet 1, and you then delete the sheet, the name is gone. Same happens in excel.
Lars Arvidsson, Axolot Data
huseyinxy
Posts: 13
Joined: Wed Oct 07, 2015 7:41 am

Re: CopySheet and delete sheet do not adjust defined cell names

Post by huseyinxy »

Hello,
You are right if i delete the sheet, the name is gone. But, CopySheet was do adjusting that names before in version TXlsReadWriteII with xls files.
Sample code with TXlsReadWriteII component works correct but not worked with TXlsReadWriteII5 component as i expected.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: CopySheet and delete sheet do not adjust defined cell names

Post by larsa »

Hello

Adjust to what? If you delete the reference source there is no logic to adjust it to anything else.
Lars Arvidsson, Axolot Data
huseyinxy
Posts: 13
Joined: Wed Oct 07, 2015 7:41 am

Re: CopySheet and delete sheet do not adjust defined cell names

Post by huseyinxy »

Hello,

I copy the old sheet before delete.
Adjust the name reference sheet to new sheetname.
( name : d_one reference : Sheet1!$D$1 --> name : d_one reference : Sheet3!$D$1 )

I send my test excel file:
https://dl.dropboxusercontent.com/u/285 ... column.rar

Test code is same before

Please test with XLSReadWriteII and XLSReadWriteII5 components with same excel file that i send, two components give different results.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: CopySheet and delete sheet do not adjust defined cell names

Post by larsa »

Hello

If you open your file in Excel and delete the sheet with the name, the name is gone. XLSReadWriteII 5 works in the same way. If version 4 did something different that was an error.
Lars Arvidsson, Axolot Data
Post Reply