cmdFormat.Apply applies to all rows and gives large files

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
datasbjorn
Posts: 1
Joined: Wed Aug 07, 2013 1:57 pm

cmdFormat.Apply applies to all rows and gives large files

Post by datasbjorn »

Hi,

In Axolot 5 - On Export setting the regions that you don't want to protect using the code below, works as expected, however, when you then read the worksheet the row count reported by Excel and used to load just the rows with data in them into memory is incorrect.

//writing file, unlocking a region.
self.oXLS.CmdFormat.BeginEdit(self.oXLS[0]);
self.oXLS.CmdFormat.Protection.Locked := False;
self.oXLS.CmdFormat.Apply(iC1, iR1, iC2, iR2);

//then setting password.
self.oXLS[0].Protection.Password := FsExcelPassword;


On reading the file when I now get the Excel row count it says there are 65536 rows in the worksheet when in fact there are only 6. This is causing a problem when loading the data into memory for validating. When we use the OLE Excel Protection methods the Excel row count is not affected.

Can you help?

Thanks in advance.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: cmdFormat.Apply applies to all rows and gives large files

Post by larsa »

Hello

If you want to format a large area of a worksheet, format the columns as this will not add any rows or cells.

Example:

Code: Select all

self.oXLS.CmdFormat.BeginEdit(self.oXLS[0]);
self.oXLS.CmdFormat.Protection.Locked := False;
self.oXLS.CmdFormat.ApplyCols(iC1, iC2);
Lars Arvidsson, Axolot Data
Post Reply