Column Width result an access violation

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
Mig_2000
Posts: 4
Joined: Thu Jan 29, 2009 10:11 pm

Column Width result an access violation

Post by Mig_2000 »

Hi,

I have an error when i tried to set a column width in my excel file with xlsreadwrite version 4.00.15

I put this code
XLS.Sheet[0].Columns[0].Width := 12;

and i have an access violation in the unit Columns4.pas on the Fwidth := Value; in this procedure

procedure TXLSColumn.SetWidth(Value: integer);
begin
if (Value < 0) or (Value > $FFFF) then
raise Exception.Create('Invalid value');
FWidth := Value;
end;


FWidth is an inacessible value and i don't know why ?

It is a bug or my error ?

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

Re: Column Width result an access violation

Post by larsa »

Hello

You must first ensure that there is a column object. Use XLS.Sheets[0].Columns.AddIfNone(Col,Count).
Lars Arvidsson, Axolot Data
indigomage
Posts: 3
Joined: Tue May 17, 2005 9:54 am
Location: Farnborough, UK
Contact:

Re: Column Width result an access violation

Post by indigomage »

How do I count the number of columns on a Sheet?

I know that I have written some columns and some sheets, but each instance will be different, and I want to auto size all the columns
You have a count of the number of sheets, but how do I get this for Columns
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Column Width result an access violation

Post by larsa »

Hello

What has your question to with the postings in this thread? Also, this thread is 6 years old. Please start a new thread.
Lars Arvidsson, Axolot Data
Post Reply