Format Cells

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
pl00
Posts: 11
Joined: Sat Feb 09, 2013 8:44 pm

Format Cells

Post by pl00 »

I'm having difficulty formatting cells on a worksheet. I'm only trying to set three attributes, viz.
. the number format (on floats and dates);
. bolding; and
. Horizontal alignment.

If I attempt to set all cells using the same format (Cell[Col,Row].NumberFormat ....) all is fine (and I can setup as many as I like). However, if I have a mixture of different formats, after setting several cells, an exception is raised when executing the function TXc12DataStyleSheet.FindEqualStyle.

I've tried setting the Default format first (following the examples in FormatCells); it works for some, but not others.

I've tried using CmdFormat (again following the exampes in FormatCells), but this doesn work at all.

I'm using the latest release (5.10 downloaded a couple of days ago). I'd really appreciate some assistance (the inability to set cell formats is not a show stopper, but I'd like to get it implemented before it does).
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Format Cells

Post by larsa »

Hello

Use the XLS.CmdFormat object for formatting cells. Please study the FormatCells sample for more details.
Lars Arvidsson, Axolot Data
mario
Posts: 8
Joined: Mon Feb 25, 2013 10:39 am

Re: Format Cells

Post by mario »

Unfortunately I have the same problem with Bold style.
When I try to follow the FormatCells sample or simply when I run it, I got this error:
E2010 Incompatible Types: 'TXc12FontStyles' and 'set'

Thanks in advance
pl00
Posts: 11
Joined: Sat Feb 09, 2013 8:44 pm

Re: Format Cells

Post by pl00 »

I believe I've followed the sample correctly, but it appears that the last default format saved is the only one returned irrespective of the selection method used.

>Use the XLS.CmdFormat object for formatting cells. Please study the FormatCells sample for more details
pl00
Posts: 11
Joined: Sat Feb 09, 2013 8:44 pm

Re: Format Cells

Post by pl00 »

5.10.03 seems to have resolved most of the issues.

However, attempting to set up a default format for a date doesn't work, example

FXLS.CmdFormat.BeginEdit(Nil);
FXLS.CmdFormat.Number.Format := 'dd-mmm-yyyy';
FXLS.CmdFormat.Alignment.Horizontal := chaCenter;
FXLS.CmdFormat.AddAsDefault('FCDate');

The CmdFormat entry exists and can be set as the default ok, but when writing a date to the cell, the incorrect format is displayed and, I think the value is corrupted because if I format the cell inthe resulting excel file an incorrect date displayed.

I can set the the cell format after it's written ok using
....NumberFormat := 'dd mmm yyyy'
but at least until verions 5.10.02 to make this work I also needed to change the font size eg
....FontSize := 11.0001
(Haven't bothered to test it with 5.10.03 - I'll wait until you fix the Default format method.)
Post Reply