Page 1 of 1

CopySheet and delete sheet do not adjust defined cell names

Posted: Thu Dec 10, 2015 8:58 am
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;



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

Posted: Mon Dec 21, 2015 10:02 am
by larsa
Hello

If the name is on sheet 1, and you then delete the sheet, the name is gone. Same happens in excel.

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

Posted: Mon Dec 21, 2015 3:23 pm
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.

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

Posted: Wed Dec 23, 2015 10:48 am
by larsa
Hello

Adjust to what? If you delete the reference source there is no logic to adjust it to anything else.

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

Posted: Thu Dec 24, 2015 7:17 am
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.

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

Posted: Mon Dec 28, 2015 9:38 am
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.