FlexCel Reports - hide gridlines and headers

Hi Adrian

I've just started developing a new report, and I'd like the final output .xlsx file to have grid lines hidden and also the row and column headers (ie the A,B,C etc & 1,2,3 etc) to be hidden. However, I'd prefer to keep my template with the grid lines and header visible, as it makes it easier to make changes to the template.

So, I'm currently creating a TXlsFile, running the report with TFlexCelReport.Run(XLSFile), and then doing XLSFile.ShowGridLines:=FALSE to hide the grid lines before saving the OutputFile.

However, I can't find an option to hide the headers. I've tried using APIMate to find the option, but no luck! Can you tell me how I can hide the row/col headers.

Steve Collins


Actually APIMate does show you the code (if you try to compile it you will see it produces a file without headers), but I agree it isn't trivial to find. I'll see if maybe a comment can be added for APIMate or what can be done to make it easier to find.

The thing is, all this stuff is set in xls.SheetOptions (see http://www.tmssoftware.biz/flexcel/doc/vcl/api/FlexCel.Core/TExcelFile/SheetOptions.html and more relevant http://www.tmssoftware.biz/flexcel/doc/vcl/api/FlexCel.Core/TSheetOptions.html )

APIMAte Reports for Delphi:

  //There are 2 ways to set the sheet options. You can use the code above to set them all, or the commented code after it to set them one by one.
  xls.SheetOptions := TSheetOptions(176);
  //  xls.ShowGridLines := false;

Which I don't know why it isn't showing individual values. I'll see to fix it. In FlexCel.NET it is better:

   //There are 2 ways to set the sheet options. You can use the code above to set them all, or the commented code after it to set them one by one.
    xls.SheetOptions = TSheetOptions.ZeroValues | TSheetOptions.AutomaticGridLineColors | TSheetOptions.OutlineSymbols;
    //    xls.ShowGridLines = false;

But well, in both cases the problem is that TSheetOptions.ShowRowAndColumnHeaders must be 1 (not 0) in the most common case, so it doesn't appear in the SheetOptions reported by APIMate.

Also most of those sheetoptions have convenience methods like "xls.ShowFormulaText" which you can use instead of setting SheetOptions directly, but as you can see in http://www.tmssoftware.biz/flexcel/doc/vcl/api/FlexCel.Core/TSheetOptions.html ShowHeaders doesn't have a method.

But in short, just do   

 xls.SheetOptions := TSheetOptions(integer(xls.SheetOptions) and not integer(TSheetOptions.ShowRowAndColumnHeaders));

to suppress display of headers. And remember this is by sheet, so if you have more than 1 sheet, you will have to loop over each one hiding the headers in every one.
Thanks for the prompt reply, Adrian.

I was looking at the FlexCel source code last night after I'd sent the original message, and right next to ShowGridLines in _UXlsAdapter.XlsFile is ShowGridHeadings!!  I've set that to FALSE and it seems to work!

Is there any reason why I shouldn't use this, or had you maybe forgotten about this 'convenience method'  ;)

Hi Steve,

I just forgot about it, and yep, you can use it :)

I'll add it to the docs in TSheetOptions now so I don't forget it next time...

Great, thanks!