Garbage content in Flexcel report

Good day

 
I have a number of Flexcel Reports, built with Flexcel 3.x. They used to use a Flexcel 3 XLSAdapter but I have replaced these with XLSXAdapters. I have removed the original unit reference in the uses section of my datamodule so there is only one for the xlsxadapter from Flexcel 5.
 
I am using these in an Intraweb v12 program and have now found that, when I stream the spreadsheet for downloading, I get a message that the file contains unreadable content and then get a file with garbage. The only thing I have changed is to replace xlsadapter with xlsxadapter and change the associations so that everything is properly linked e.g. FlexcelReport to XLSXAdapter. My template spreadsheets are still .xls files.
 
Any suggestions for what could be causing this?
 
Thanks
   Bruce

Hi,


The first thing to do would be to verify this isn't a problem with the streaming of the file (which I think is more likely).
If you save the file locally to a tmp location before streaming it, is the tmp file also garbage?

If it is, then there is something wrong with FlexCel. If it isn't then there is something wrong with how you are streaming the file. If the problem is with the tmp file, please sent it to me to adrian@tmssoftware.com  If the file is ok, then can you tell me the exact code you are using for streaming?

Also note that if you changed xls to xlsx, the mime type should change too:
.xlsx:   application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xlsm: application/vnd.ms-excel.sheet.macroEnabled.12

from:
http://technet.microsoft.com/en-us/library/ee309278(office.12).aspx

Hi Adrian

  will have to work out how to save and check the tmp file as you suggest. For the moment, here is my code for streaming. All this is done with Intraweb 12.2.12.1 and Delphi XE2. I don't ever set anything as a mime header. Presumably this gets handled by Intraweb?
 
procedure TISFGrid.iwbDownloadClick(Sender: TObject);
var
  MemStream: TMemoryStream;
  l,i : integer;
  tmpUser : string;
begin
  tmpUser := UserSession.UserID;
  dmStrat.qRep1.Close;
  dmStrat.qRep1.SQL.Clear;
  dmStrat.qRep1.SQL.Text := dmStrat.Query1.SQL.Text;
  dmStrat.qRep1.ParamByName('USERID').AsString := tmpUser;
  dmStrat.qRep2.ParamByName('USERID').AsString := tmpUser;
  dmStrat.qRep3.ParamByName('USERID').AsString := tmpUser;
  dmStrat.qRep4.ParamByName('USERID').AsString := tmpUser;
  dmStrat.cdsRep1.Close;
  dmStrat.cdsRep1.Open;
  dmStrat.cdsRep1.First;
  //dmUser.SetDeveloperData(dmStrat.qRep1.SQL.Text);
  dmStrat.FlexCelReport1.Template := WebApplication.ApplicationPath+'wwwroot\Files\Flexcell\FlxStratUnits.xls';
  MemStream:=TMemoryStream.Create;
  try
    dmStrat.FlexCelReport1.SavetoStream(MemStream);
    WebApplication.SendStream(MemStream,true,'','Strat_Units.xls'); //save as an attachment
    MemStream:=nil; //If we actually sent the stream, WebApplication.SendStream will free it.
  finally
    FreeAndNil(MemStream);
    dmStrat.cdsRep1.Close;
  end; //finally
end;
Regards
   Bruce
 
Regards
   Bruce

Well, I've tried a code similar to this and seems to be working fine here. IW is 12.0.8 (the default that comes with XE), because that is what I have installed, but I imagine it won't have broke from 12.0 to 12.2 (maybe I am being naive...)


About the mime file, you should specify one or at least make sure you use the same file format everywhere. In the example I tried here, when I click "Open" in ie, I get a warning form Excel: "The file is not in the file format specified".(but if I click ok, the file opens fine).

You need to synchronize 3 different places:
1) The file format FlexCel itself is generating. When you save to a file, FlexCel knows what you want to save from the extension, so if you save as "something.xls", FlexCel will generate an xls file, and if you save as "Something.xlsx", then FlexCel will generate an xlsx file.

But, if you are saving to a stream as in this case, FlexCel can't guess what format you want. So you need to explicitly say it in the XlsxAdapter "SaveFormat" property.

In the object inspector for the XlsxAdapters, look at the "SaveFormat" property and set it to xls or xlsx as you want. Note that if you leave the default (auto) streams will be saved as xlsx.

2)The file format you send to the browser must be the same as 1). In your case, you are doing:
    WebApplication.SendStream(MemStream,true,'','Strat_Units.xls'); //save as an attachment

But if you left the XlsxAdapter.SaveFormat = snAuto, then the file will be actually xlsx and Excel 2010 will complain.
So you either set the SaveFormat = snXls, or call: 
    WebApplication.SendStream(MemStream,true,'','Strat_Units.xlsx'); //save as an attachment

Probably as the templates are xls, the best is to keep the file format xls, to avoid a conversion. So I would change the SaveFormat to be xls.

3)In the line:
    WebApplication.SendStream(MemStream,true,'','Strat_Units.xls'); //save as an attachment

You can specify the mime type, like:
    WebApplication.SendStream(MemStream,true,'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','Strat_Units.xlsx'); //save as an attachment

But it looks like indeed, IW handles this automatically, so probably the best is to keep the mime empty. Because if you change it, you will have to set the correct one depending if it is xls, xlsx or xlsm.

So well, please try it with SaveMode= snXls and see if it works better. If not, we will have to see that generated file before streaming to locate the problem.

Hi Adrian

  thanks, that gives me more to work with. I have tried a few things and have encountered some other problems that you may wish to check on.
 
1) I did not realise that the output format was specifically tied to the SaveFormat in the xlsxadapter. I thought that this was a way to specify several different formats that could be selected at run time. As a result, I was checking three boxes (snxAuto, snxXLS and snsXLSX). Now, when I check only the snxXLS box, I get correct exporting.
 
2) Some of my exported spreadsheets have the potential to be quite large and I did not want to exceed the row limit of the XLS format. I know at design time which flexcel reports might become very large so decided to allow for this. In my datamodule I added another XLSXadapter. The original one I called XLSXAdapterXLS and the second one is called XLSXAdapterXLSX. For a report which may get large, I associated the report with XLSXAdapterXLSX and for the others with XLSXAdapterXLS.
 
For XLSXAdapterXLSX I set the SaveFormat to only snxXLSX. I made a template which was in XLSX format so that there would not be any conversion and also specify the output spreadsheet name to be a .XLSX file.
 
Now, when I run a check on my FlexcelReport (the one that uses the XLSXAdapterXLSX, which has a .xlsx template) I get an error message 'The file "" is invalid'
 
 
If one can only choose one of the SaveFormats, then I suggest that you only allow one checkbox to be selected. If one is supposed to be able to select multiple saveformats then I think there is a bug in your code. There certainly seems to be a bug when one has two XLSXAdapters on a datamodule or form and one of these points to XLSX format templates.
 
Thanks
   Bruce
 

Bruce,


[quote]
If one can only choose one of the SaveFormats, then I suggest that you only allow one checkbox to be selected. If one is supposed to be able to select multiple saveformats then I think there is a bug in your code. There certainly seems to be a bug when one has two XLSXAdapters on a datamodule or form and one of these points to XLSX format templates.
[quote]

It is not a bug, it is that it works in a different way. A way that is actually not so intuitive, and that is why FlexCel 5 doesn't do it anymore. 

But well, the idea is that you can save more than one file at the same time. If you select snXls and snXlsx, the file will be saved twice when you execute FlexCelReport.Run. When we added this a lot of time ago it made sense, so if you wanted 2 different formats you could run the report once and have the 2 files generated. Also by the time we defined this (about 2002) there was an OLEAdapter besides XlsAdapter, which could save in many formats, like Excel 95, lotus 123, etc. Much of the weird parts of FlexCelReport are workarounds we had to do to make OleAdapter work.

Of course, in your case, SaveToStream(...) will only save one file format, it can't save many ones, but for the more common case that you run the report from a template to a file, it can make sense. Actually I myself have very old apps using this feature, and we are not going to do breaking changes in v3 unless it is really necessary. This is a case where it isn't, and we can potentially break a lot of code out there. If you are saving to streams, just select a single format from the list. If you are saving to files, remember that all the formats you select will be saved (And there is an event something like GetFileName where you can name every one of those files generated in a single run).

As said, I understand this isn't as intuitive as it could be, but v3 was designed a very long time ago (first FlexCel version is from 1996) and things were quite different back then. This is a little the reason why we redesigned it in FlexCel 5.

Now, about your error with XlsxAdapterXlsx, sorry if I ask something silly, but can you make real sure you are using an XlsxAdapter and not XlsAdapter? Maybe there is some old XlsAdapter around and it is linked to the report instead of the one you htink you are linking?

I say this because the message "the file "" is invalid" is only thrown by XlsAdapter. 
XlsxAdapter should say 'The file format is not xls 5 or up.' when the same error happens, and it will never say "the file "" is invalid".  
And of course, it would make sense that if it is an XlsAdapter, it can't read xlsx files and so it throws the ErrFileIsNotXls exception.

Hi Adrian

 
I am not aware of any XLSAdapter component still in the datamodule (I only find two XLSXAdapters). I originally deleted the XLSAdapter in the uses statement and tried deleting all othe Flexcel items in uses but they get put back when I save the file. The uses statement currently looks like the following for the datamodule (I also have other data modules but this is the one where this XLSXAdapter and FlexcelReport are). I can't imagine it being an issue from some other form or module.
 
uses
  Forms,
  SysUtils, Classes, FMTBcd, DB, SqlExpr, DBClient, Provider,
  IWCompListbox, WideStrings,
  DBXDevartInterBase, XLSXAdapter, UExcelAdapter, UFlexCelReport,
  UCustomFlexCelReport;
 
Thanks for the explanation on the rest of the workings. I see where you were coming from and now appreciate how to set up my various xlsxadapters (other than not being able to resolve the problem above).
 
Regards
   Bruce

Bruce,

Can you run your app locally, and look at the stack when the Exception happens?
Here I can reproduce your message by using an XlsAdapter, and the stack trace looks like this:



What is the stack trace you see?  Does it include XlsAdapter.TXLSFile.OpenStream as in my case?  Is it in UOle2Imp as here?  On one side it should be, because as far as I know, those are the only units that show that message. But if you are not using XlsAdapter, I don't really know what could be happening, so it wouldbe nice to know where your error is, maybe I am looking at the wrong place.

I've also uploaded the test app I am using here so you can test it and see if you get the same results.
http://tmssoftware.net/public/flexcel/samples/teststreaming.zip

The test is using XlsAdapter, if you run it "as is" you shoul get the "File "" is invalid" error. But if you change the Adapter to XlsxAdapter, it should run fine. If you can replicate this in your machine, can you modify this test so it shows the error you are getting?

Hi Adrian

 
please note that the problem I described was not when running a program, it was in the IDE when I want to do a check on a report in the Flexcel Designer. At this oint, if I double click on the flexcelReport, linked to a XLSXAdapter which points to an xlsx file, I get the message 'The file "" is invalid'. The stack trace (details) for the error are:
 
[19E8AE64]{FlexCelXE2.bpl} Uole2impl.TOle2Header + $290
[19E8C890]{FlexCelXE2.bpl} Uole2impl.TOle2File + $7C
[5003C547]{rtl160.bpl  } System.TObject.NewInstance (Line 13000, "System.pas" + 1) + $10
[19E8C7ED]{FlexCelXE2.bpl} Uole2impl.TOle2File + $25
[19EF0FA4]{FlexCelXE2.bpl} Xlsadapter.TXLSFile.OpenStream + $4C
[19EF1214]{FlexCelXE2.bpl} Xlsadapter.TXLSFile.OpenFileAndOrSearch + $EC
[19EF111C]{FlexCelXE2.bpl} Xlsadapter.TXLSFile.OpenFileAndSearch + $14
[15E43CB2]{FlexCelXE2_DESIGN.bpl} Uchecktemplate.TCheckTemplate.Check + $14A
[15E436E3]{FlexCelXE2_DESIGN.bpl} Uchecktemplate.InvokeCheckTemplate + $1DB
[15E462D7]{FlexCelXE2_DESIGN.bpl} Uexceledit.TExcelEdit.ActionCheckTemplateExecute + $73
[500B5B97]{rtl160.bpl  } System.Classes.TBasicAction.Execute (Line 13372, "System.Classes.pas" + 3) + $7
[5031B86D]{vcl160.bpl  } Vcl.ActnList.TContainedAction.Execute (Line 448, "Vcl.ActnList.pas" + 8) + $2C
[5031C658]{vcl160.bpl  } Vcl.ActnList.TCustomAction.Execute (Line 1094, "Vcl.ActnList.pas" + 7) + $8
[0B6A894E]{IDEFixPack.dll} UnregisterChangeDirectoryNotifier + $9C1A
[500B5A5B]{rtl160.bpl  } System.Classes.TBasicActionLink.Execute (Line 13301, "System.Classes.pas" + 2) + $7
[50332ED4]{vcl160.bpl  } Vcl.Controls.TControl.Click (Line 7318, "Vcl.Controls.pas" + 7) + $7
[503ACE98]{vcl160.bpl  } Vcl.ComCtrls.TToolButton.Click (Line 21225, "Vcl.ComCtrls.pas" + 0) + $0
[50333395]{vcl160.bpl  } Vcl.Controls.TControl.WMLButtonUp (Line 7459, "Vcl.Controls.pas" + 7) + $6
[50332995]{vcl160.bpl  } Vcl.Controls.TControl.WndProc (Line 7204, "Vcl.Controls.pas" + 91) + $6
[503325D0]{vcl160.bpl  } Vcl.Controls.TControl.Perform (Line 6982, "Vcl.Controls.pas" + 10) + $8
[50336A40]{vcl160.bpl  } Vcl.Controls.GetControlAtPos (Line 9712, "Vcl.Controls.pas" + 4) + $76
[50336B0A]{vcl160.bpl  } Vcl.Controls.TWinControl.ControlAtPos (Line 9735, "Vcl.Controls.pas" + 13) + $E
[503325D0]{vcl160.bpl  } Vcl.Controls.TControl.Perform (Line 6982, "Vcl.Controls.pas" + 10) + $8
[50336BD4]{vcl160.bpl  } Vcl.Controls.TWinControl.IsControlMouseMsg (Line 9759, "Vcl.Controls.pas" + 15) + $2A
[5033716F]{vcl160.bpl  } Vcl.Controls.TWinControl.WndProc (Line 9927, "Vcl.Controls.pas" + 103) + $6
[503AEFA5]{vcl160.bpl  } Vcl.ComCtrls.TToolBar.UpdateButtonState (Line 22492, "Vcl.ComCtrls.pas" + 11) + $27
[503AEFE6]{vcl160.bpl  } Vcl.ComCtrls.TToolBar.UpdateButtonStates (Line 22503, "Vcl.ComCtrls.pas" + 3) + $4
[503B1964]{vcl160.bpl  } Vcl.ComCtrls.TToolBar.WndProc (Line 24078, "Vcl.ComCtrls.pas" + 104) + $6
[50336948]{vcl160.bpl  } Vcl.Controls.TWinControl.MainWndProc (Line 9689, "Vcl.Controls.pas" + 3) + $6
[500B688C]{rtl160.bpl  } System.Classes.StdWndProc (Line 13878, "System.Classes.pas" + 8) + $0
[50454598]{vcl160.bpl  } Vcl.Forms.TApplication.CancelHint (Line 10993, "Vcl.Forms.pas" + 6) + $7
[50453213]{vcl160.bpl  } Vcl.Forms.TApplication.ProcessMessage (Line 10164, "Vcl.Forms.pas" + 23) + $1
[50453256]{vcl160.bpl  } Vcl.Forms.TApplication.HandleMessage (Line 10194, "Vcl.Forms.pas" + 1) + $4
[5044EA75]{vcl160.bpl  } Vcl.Forms.TCustomForm.ShowModal (Line 7035, "Vcl.Forms.pas" + 33) + $5
[15E458AE]{FlexCelXE2_DESIGN.bpl} Uexceledit.InvokeExcelEditor + $72
[15E468A4]{FlexCelXE2_DESIGN.bpl} Dflexcelreporteditor.TFlexCelReportEditor.ExecuteVerb + $90
[20FAFE98]{designide160.bpl} DesignEditors.TComponentEditor.Edit (Line 2687, "DesignEditors.pas" + 1) + $11
[20FD9E6D]{designide160.bpl} ComponentDesigner.TInternalItem.Edit (Line 7200, "ComponentDesigner.pas" + 1) + $F
[20FA0D58]{designide160.bpl} Designer.TDesigner.Edit (Line 974, "Designer.pas" + 0) + $4
[20FA304F]{designide160.bpl} Designer.TDesigner.MouseDown (Line 1673, "Designer.pas" + 50) + $6
[51D3A789]{vcldesigner160.bpl} VCLSurface.TComponentToolWindow.WndProc (Line 1335, "VCLSurface.pas" + 16) + $32
[51D3B22B]{vcldesigner160.bpl} VCLSurface.TContainer.WndProc (Line 1635, "VCLSurface.pas" + 39) + $6
[51D3A5AB]{vcldesigner160.bpl} VCLSurface.TDesignerToolWindow.MainWndProc (Line 1270, "VCLSurface.pas" + 2) + $7
[500B688C]{rtl160.bpl  } System.Classes.StdWndProc (Line 13878, "System.Classes.pas" + 8) + $0
[5032D7BE]{vcl160.bpl  } Vcl.Controls.FindControl (Line 3540, "Vcl.Controls.pas" + 6) + $9
[50453213]{vcl160.bpl  } Vcl.Forms.TApplication.ProcessMessage (Line 10164, "Vcl.Forms.pas" + 23) + $1
[50453256]{vcl160.bpl  } Vcl.Forms.TApplication.HandleMessage (Line 10194, "Vcl.Forms.pas" + 1) + $4
[50453595]{vcl160.bpl  } Vcl.Forms.TApplication.Run (Line 10332, "Vcl.Forms.pas" + 26) + $3
 
When I take the program you supplied, I defined the template for the FlexcelReport1 to be the testtemplate.xls (starting with the version as provided in which the FlexcelReport uses XLSAdapter1. If I click on Check in the Flexcel Designer, everything checks out fine.
 
If I now change the FlexcelReport1 to use XLSXAdapter1 but keep the template file as testtemplate.xls, check works fine.
 
If I use XLSXAdapter1 but set the template to testtemplate.xlsx I get the same 'The file "" is invalid' error and the stack trace is:
 
[19E8AE64]{FlexCelXE2.bpl} Uole2impl.TOle2Header + $290
[19E8C890]{FlexCelXE2.bpl} Uole2impl.TOle2File + $7C
[5003C547]{rtl160.bpl  } System.TObject.NewInstance (Line 13000, "System.pas" + 1) + $10
[19E8C7ED]{FlexCelXE2.bpl} Uole2impl.TOle2File + $25
[19EF0FA4]{FlexCelXE2.bpl} Xlsadapter.TXLSFile.OpenStream + $4C
[19EF1214]{FlexCelXE2.bpl} Xlsadapter.TXLSFile.OpenFileAndOrSearch + $EC
[19EF111C]{FlexCelXE2.bpl} Xlsadapter.TXLSFile.OpenFileAndSearch + $14
[15E43CB2]{FlexCelXE2_DESIGN.bpl} Uchecktemplate.TCheckTemplate.Check + $14A
[15E436E3]{FlexCelXE2_DESIGN.bpl} Uchecktemplate.InvokeCheckTemplate + $1DB
[15E462D7]{FlexCelXE2_DESIGN.bpl} Uexceledit.TExcelEdit.ActionCheckTemplateExecute + $73
[500B5B97]{rtl160.bpl  } System.Classes.TBasicAction.Execute (Line 13372, "System.Classes.pas" + 3) + $7
[5031B86D]{vcl160.bpl  } Vcl.ActnList.TContainedAction.Execute (Line 448, "Vcl.ActnList.pas" + 8) + $2C
[5031C658]{vcl160.bpl  } Vcl.ActnList.TCustomAction.Execute (Line 1094, "Vcl.ActnList.pas" + 7) + $8
[0B6A894E]{IDEFixPack.dll} UnregisterChangeDirectoryNotifier + $9C1A
[500B5A5B]{rtl160.bpl  } System.Classes.TBasicActionLink.Execute (Line 13301, "System.Classes.pas" + 2) + $7
[50332ED4]{vcl160.bpl  } Vcl.Controls.TControl.Click (Line 7318, "Vcl.Controls.pas" + 7) + $7
[503ACE98]{vcl160.bpl  } Vcl.ComCtrls.TToolButton.Click (Line 21225, "Vcl.ComCtrls.pas" + 0) + $0
[50333395]{vcl160.bpl  } Vcl.Controls.TControl.WMLButtonUp (Line 7459, "Vcl.Controls.pas" + 7) + $6
[50332995]{vcl160.bpl  } Vcl.Controls.TControl.WndProc (Line 7204, "Vcl.Controls.pas" + 91) + $6
[503325D0]{vcl160.bpl  } Vcl.Controls.TControl.Perform (Line 6982, "Vcl.Controls.pas" + 10) + $8
[50336A40]{vcl160.bpl  } Vcl.Controls.GetControlAtPos (Line 9712, "Vcl.Controls.pas" + 4) + $76
[50336B0A]{vcl160.bpl  } Vcl.Controls.TWinControl.ControlAtPos (Line 9735, "Vcl.Controls.pas" + 13) + $E
[503325D0]{vcl160.bpl  } Vcl.Controls.TControl.Perform (Line 6982, "Vcl.Controls.pas" + 10) + $8
[50336BD4]{vcl160.bpl  } Vcl.Controls.TWinControl.IsControlMouseMsg (Line 9759, "Vcl.Controls.pas" + 15) + $2A
[5033716F]{vcl160.bpl  } Vcl.Controls.TWinControl.WndProc (Line 9927, "Vcl.Controls.pas" + 103) + $6
[503AEFA5]{vcl160.bpl  } Vcl.ComCtrls.TToolBar.UpdateButtonState (Line 22492, "Vcl.ComCtrls.pas" + 11) + $27
[503AEFE6]{vcl160.bpl  } Vcl.ComCtrls.TToolBar.UpdateButtonStates (Line 22503, "Vcl.ComCtrls.pas" + 3) + $4
[503B1964]{vcl160.bpl  } Vcl.ComCtrls.TToolBar.WndProc (Line 24078, "Vcl.ComCtrls.pas" + 104) + $6
[50336948]{vcl160.bpl  } Vcl.Controls.TWinControl.MainWndProc (Line 9689, "Vcl.Controls.pas" + 3) + $6
[500B688C]{rtl160.bpl  } System.Classes.StdWndProc (Line 13878, "System.Classes.pas" + 8) + $0
[50454598]{vcl160.bpl  } Vcl.Forms.TApplication.CancelHint (Line 10993, "Vcl.Forms.pas" + 6) + $7
[50453213]{vcl160.bpl  } Vcl.Forms.TApplication.ProcessMessage (Line 10164, "Vcl.Forms.pas" + 23) + $1
[50453256]{vcl160.bpl  } Vcl.Forms.TApplication.HandleMessage (Line 10194, "Vcl.Forms.pas" + 1) + $4
[5044EA75]{vcl160.bpl  } Vcl.Forms.TCustomForm.ShowModal (Line 7035, "Vcl.Forms.pas" + 33) + $5
[15E458AE]{FlexCelXE2_DESIGN.bpl} Uexceledit.InvokeExcelEditor + $72
[15E468A4]{FlexCelXE2_DESIGN.bpl} Dflexcelreporteditor.TFlexCelReportEditor.ExecuteVerb + $90
[20FAFE98]{designide160.bpl} DesignEditors.TComponentEditor.Edit (Line 2687, "DesignEditors.pas" + 1) + $11
[20FD9E6D]{designide160.bpl} ComponentDesigner.TInternalItem.Edit (Line 7200, "ComponentDesigner.pas" + 1) + $F
[20FA0D58]{designide160.bpl} Designer.TDesigner.Edit (Line 974, "Designer.pas" + 0) + $4
[20FA304F]{designide160.bpl} Designer.TDesigner.MouseDown (Line 1673, "Designer.pas" + 50) + $6
[51D3A789]{vcldesigner160.bpl} VCLSurface.TComponentToolWindow.WndProc (Line 1335, "VCLSurface.pas" + 16) + $32
[51D3B22B]{vcldesigner160.bpl} VCLSurface.TContainer.WndProc (Line 1635, "VCLSurface.pas" + 39) + $6
[51D3A5AB]{vcldesigner160.bpl} VCLSurface.TDesignerToolWindow.MainWndProc (Line 1270, "VCLSurface.pas" + 2) + $7
[500B688C]{rtl160.bpl  } System.Classes.StdWndProc (Line 13878, "System.Classes.pas" + 8) + $0
[50454598]{vcl160.bpl  } Vcl.Forms.TApplication.CancelHint (Line 10993, "Vcl.Forms.pas" + 6) + $7
[50453213]{vcl160.bpl  } Vcl.Forms.TApplication.ProcessMessage (Line 10164, "Vcl.Forms.pas" + 23) + $1
[50453256]{vcl160.bpl  } Vcl.Forms.TApplication.HandleMessage (Line 10194, "Vcl.Forms.pas" + 1) + $4
[50453595]{vcl160.bpl  } Vcl.Forms.TApplication.Run (Line 10332, "Vcl.Forms.pas" + 26) + $3
By the way, if I try to compile your program, it will not compile with both XLSAdapter and XLSXAdapter defined. I get the following error message:
 
dcc command line for "teststreaming.dpr"
  c:\program files\embarcadero\rad studio\9.0\bin\dcc32.exe -$O- -$W+ --no-config -M -Q -TX.exe -AGenerics.Collections=System.Generics.Collections;
  Generics.Defaults=System.Generics.Defaults;WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DDEBUG -I"c:\program
  files\embarcadero\rad studio\9.0\Imports";"C:\Users\Public\Documents\RAD Studio\9.0\Dcp";c:\dcpxe2;"C:\Users\bre255\AppData\Roaming\IntraWeb
  XII\Libxe2W32";"c:\program files\embarcadero\rad studio\9.0\lib\win32\debug";"c:\program files\embarcadero\rad studio\9.0\lib\win32\release";
  "C:\Program Files\FFVCL_Trial\Dcp";c:\users\bre255\documents\tmssoftware\flexcelvcl\source\win32\release;
  C:\Users\bre255\Documents\TMSSoftware\FlexCelVCLNT\Packages\dXE2\Win32\Release;C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\dcu\XE2\Win32;
  C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\Source -LE"C:\Users\Public\Documents\RAD Studio\9.0\Bpl" -LN"C:\Users\Public\Documents\RAD
  Studio\9.0\Dcp" -NSWinapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;
  Data;Datasnap;Web;Soap;FlexCel; -O"c:\program files\embarcadero\rad studio\9.0\Imports";"C:\Users\Public\Documents\RAD Studio\9.0\Dcp";c:\dcpxe2;
  "C:\Users\bre255\AppData\Roaming\IntraWeb XII\Libxe2W32";"c:\program files\embarcadero\rad studio\9.0\lib\win32\debug";"c:\program
  files\embarcadero\rad studio\9.0\lib\win32\release";"C:\Program Files\FFVCL_Trial\Dcp";
  c:\users\bre255\documents\tmssoftware\flexcelvcl\source\win32\release;C:\Users\bre255\Documents\TMSSoftware\FlexCelVCLNT\Packages\dXE2\Win32\Release;
  C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\dcu\XE2\Win32;C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\Source -R"c:\program
  files\embarcadero\rad studio\9.0\Imports";"C:\Users\Public\Documents\RAD Studio\9.0\Dcp";c:\dcpxe2;"C:\Users\bre255\AppData\Roaming\IntraWeb
  XII\Libxe2W32";"c:\program files\embarcadero\rad studio\9.0\lib\win32\debug";"c:\program files\embarcadero\rad studio\9.0\lib\win32\release";
  "C:\Program Files\FFVCL_Trial\Dcp";c:\users\bre255\documents\tmssoftware\flexcelvcl\source\win32\release;
  C:\Users\bre255\Documents\TMSSoftware\FlexCelVCLNT\Packages\dXE2\Win32\Release;C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\dcu\XE2\Win32;
  C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\Source -U"c:\program files\embarcadero\rad studio\9.0\Imports";"C:\Users\Public\Documents\RAD
  Studio\9.0\Dcp";c:\dcpxe2;"C:\Users\bre255\AppData\Roaming\IntraWeb XII\Libxe2W32";"c:\program files\embarcadero\rad studio\9.0\lib\win32\debug";
  "c:\program files\embarcadero\rad studio\9.0\lib\win32\release";"C:\Program Files\FFVCL_Trial\Dcp";
  c:\users\bre255\documents\tmssoftware\flexcelvcl\source\win32\release;C:\Users\bre255\Documents\TMSSoftware\FlexCelVCLNT\Packages\dXE2\Win32\Release;
  C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\dcu\XE2\Win32;C:\Users\bre255\Documents\TMSSoftware\FlexCelVCL\Source -K00400000
  -NB"C:\Users\Public\Documents\RAD Studio\9.0\Dcp" -NH"C:\Users\Public\Documents\RAD Studio\9.0\hpp"   teststreaming.dpr  
[DCC Error] Unit1.pas(16): E2003 Undeclared identifier: 'TXLSAdapter'
[DCC Error] Unit1.pas(16): E2217 Published field 'XLSAdapter1' not a class or interface type
[DCC Fatal Error] teststreaming.dpr(7): F2063 Could not compile used unit 'Unit1.pas'
Failed
Elapsed time: 00:00:05.4
 
I have seen the same with my own programs and found that I had to replace XLSAdapter with XLSXAdapter in all units of a program to get it to compile i.e. I could not mix XLSAdapter and XLSXAdapter in one program, even if defined in different units. To do this I had to remove the uses link to XLSAdapter.
 
Hope this helps.
 
Regards
   Bruce

Bruce,

Sorry, I hadn't realized the problem was with "check template", I thought it was when actually running the report. The problem here of course, is that the designer always uses an XlsAdapter, no matter what is attached. This is because originally there was a OleAdapter and XlsAdapter, and OleAdapter couldn't do what was needed. So if the adapter isn't an XlsAdapter, the designer will create an XlsAdapter anyway. I think this could be solved easily, I'll see if possible. But the program should work anyway, this should be an issue only with CheckTemplate.

About the second error you are getting it looks like something is installed wrong, as you might guess, the sample app I sent compiles fine her, and I actually have projects that use both (mostly tests, because in my real projects I've removed all XlsAdapters, they don't make any more sense.) My guess is that it is some dll or dcu in the search path, but it is very weird that just because you include XlsxAdapter, then XlsAdapter gets undefined, as those are completely unrelated programs. I really don't know what to suggest here.

Hi Adrian

  sorry about the confusion and thanks for the explanation.
 
In terms of the second issue, not being able to compile programs with both XLSAdapter and XLSXAdapter, I will try to find what might be incorrectly installed or defined for paths. It is really not a big issue though as I can always replace all XLSAdapters with XLSXAdapters and everything else works now that I know to set only one SaveFormat (whichever is appropriate to the spreadsheet template and output I want).
 
As always, thanks for the excellent support.
 
Bruce