Cannot load XLSRWII 4 modified file in Excel 2007
Posted: Wed Oct 01, 2008 10:02 am
Hello
I am having a very annoying problem with XLSReadWriteII 4
When I open a spreadsheet add a sheet save it, I cannot open the file in Excel 2007
It doesn’t make any difference whether I set the version of the component to Excel 97 or Excel 2007
Both load fine with Excel XP which I have on my machine
Has anyone ever encountered this problem?
Paul
My code is below
unMain.Pas
unit unMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, XLSReadWriteII4, Cell4, XLSUtils4, BIFFRecsII4;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
objFile: TXLSReadWriteII4;
begin
begin
objFile := TXLSReadWriteII4.Create(nil);
try
objFile.Version := xvExcel2007;
objFile.Filename := 'SampleExcel2007.xls';
objFile.Read;
objFile.Sheets.Add;
objFile.Write;
finally
FreeAndnil(objFile);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
objFile: TXLSReadWriteII4;
begin
begin
objFile := TXLSReadWriteII4.Create(nil);
try
objFile.Version := xvExcel97;
objFile.Filename := 'SampleExcel97.xls';
objFile.Read;
objFile.Sheets.Add;
objFile.Write;
finally
FreeAndnil(objFile);
end;
end;
end;
end.
unMain.dfm
object Form1: TForm1
Left = 74
Top = 185
Width = 225
Height = 105
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 12
Top = 6
Width = 196
Height = 25
Caption = 'Excel 2007 Version'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 13
Top = 37
Width = 196
Height = 25
Caption = 'Excel 1997 Version'
TabOrder = 1
OnClick = Button2Click
end
end
Project file
program XLSRWProblem;
uses
Forms,
unMain in 'unMain.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
I am having a very annoying problem with XLSReadWriteII 4
When I open a spreadsheet add a sheet save it, I cannot open the file in Excel 2007
It doesn’t make any difference whether I set the version of the component to Excel 97 or Excel 2007
Both load fine with Excel XP which I have on my machine
Has anyone ever encountered this problem?
Paul
My code is below
unMain.Pas
unit unMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, XLSReadWriteII4, Cell4, XLSUtils4, BIFFRecsII4;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
objFile: TXLSReadWriteII4;
begin
begin
objFile := TXLSReadWriteII4.Create(nil);
try
objFile.Version := xvExcel2007;
objFile.Filename := 'SampleExcel2007.xls';
objFile.Read;
objFile.Sheets.Add;
objFile.Write;
finally
FreeAndnil(objFile);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
objFile: TXLSReadWriteII4;
begin
begin
objFile := TXLSReadWriteII4.Create(nil);
try
objFile.Version := xvExcel97;
objFile.Filename := 'SampleExcel97.xls';
objFile.Read;
objFile.Sheets.Add;
objFile.Write;
finally
FreeAndnil(objFile);
end;
end;
end;
end.
unMain.dfm
object Form1: TForm1
Left = 74
Top = 185
Width = 225
Height = 105
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 12
Top = 6
Width = 196
Height = 25
Caption = 'Excel 2007 Version'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 13
Top = 37
Width = 196
Height = 25
Caption = 'Excel 1997 Version'
TabOrder = 1
OnClick = Button2Click
end
end
Project file
program XLSRWProblem;
uses
Forms,
unMain in 'unMain.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.