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.
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.
//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.
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.
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' ;)