Formating Multiple Columns Failure

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
taz.higgins
Posts: 8
Joined: Wed May 29, 2013 2:57 pm

Formating Multiple Columns Failure

Post by taz.higgins »

Using version: 5.20.26

If you have multiple different column formatings on a spreadsheet all of the cells that have data in them on the sheet (as opposed to blank cells blank) get set to the LAST columns formating applied, overriding all previous column formating.
This completly breaks the formating of sheets. (I have sheets with comma seperated numbers, non comma seperated numbers, different displayed precisions etc)

To reproduce this here are the following steps
Take the sameplformatcells project supplied with XLSRWII5. Stick a new button on it (Button 2) and here is the code for that button

procedure TfrmMain.Button2Click(Sender: TObject);
begin
XLS[0].AsFloat[1,1] := 1111.1111;
XLS[0].AsFloat[2,2] := 2222.2222;
XLS[0].AsFloat[3,3] := 3333.3333;

XLS.CmdFormat.Mode := xcfmMerge;
XLS.CmdFormat.BeginEdit(XLS[0]);

XLS.CmdFormat.Number.Format := '[Red]#,0';
XLS.CmdFormat.ApplyCols(1,1);

XLS.CmdFormat.BeginEdit(XLS[0]);
XLS.CmdFormat.Number.Format := '[Blue]0.0';
XLS.CmdFormat.ApplyCols(2,2);

XLS.CmdFormat.BeginEdit(XLS[0]);
XLS.CmdFormat.Number.Format := '[Black]0.00';
XLS.CmdFormat.ApplyCols(3,3);
end;

run it, hit the button, save the sheet and look at it in excel

What I should get is:
Cell B2: 1,111 (in red, Cell format should be [Red]#,##0)
Cell C3: 2222.2 (in blue, Cell format should be [Blue]0.0)
Cell D4: 3333.33 (in black, Cell format should be [Black]0.00)

What I do get is:
Cell B2: 1111.11 (in black, Cell format is [Black]0.00)
Cell C3: 2222.22 (in black, Cell format is [Black]0.00)
Cell D4: 3333.33 (in black, Cell format is [Black]0.00)

Look at any cell in Column B EXCEPT for B2, they all have the correct number format assigned to them i.e. [Red]#,##0
Same is true for Column C (and cell C3)

Really need a solution to this, it's completly broken out outputs to excel (which is a critical part of our products requirements).
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Formating Multiple Columns Failure

Post by larsa »

Hello

This is fixed in update 5.20.30
Lars Arvidsson, Axolot Data
taz.higgins
Posts: 8
Joined: Wed May 29, 2013 2:57 pm

Re: Formating Multiple Columns Failure

Post by taz.higgins »

Good to here it Lars.
When will .30 be available?
taz.higgins
Posts: 8
Joined: Wed May 29, 2013 2:57 pm

Re: Formating Multiple Columns Failure

Post by taz.higgins »

More formating woes:

The following doesn't work (with strFontName = 'Verdana' and nSize = 8)
procedure SetSheetFont(const XLS: TXLSReadWriteII5; const strFontName: String; const nSize, nSheetNo: Integer);
begin
XLS[nSheetNo].CalcDimensions;

XLS.CmdFormat.BeginEdit(XLS[nSheetNo]);
try
XLS.CmdFormat.Font.Name := strFontName;
XLS.CmdFormat.Font.Size := nSize;
finally
XLS.CmdFormat.Apply(0, 0, XLS[nSheetNo].LastCol, XLS[nSheetNo].LastRow);
end;
end;
Post Reply