Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Print Area - FlexCel.AspNet.FlexCelAspViewer

 Post Reply Post Reply
Author
Beketov Roman View Drop Down
New Member
New Member
Avatar

Joined: 21 Jul 2011
Posts: 22
Post Options Post Options   Quote Beketov Roman Quote  Post ReplyReply Direct Link To This Post Topic: Print Area - FlexCel.AspNet.FlexCelAspViewer
    Posted: 14 Nov 2012 at 9:51am

Hello,

I am using FlexCel.AspNet.FlexCelAspViewer to show excel file on HTML page. Having a problem showing Excel files with defined Print Area region. Only part of the excel file is shown - part that defined in the Print Area, but I need to show the whole file.

Is there any way to remove Print_Area settings from Excel file?

Is it possible to configure FlexCelAspViewer to show whole file regardles Print Area settings?

Thank you in advance,

Alexander

Back to Top
Adrian Gallero View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 1237
Post Options Post Options   Quote Adrian Gallero Quote  Post ReplyReply Direct Link To This Post Posted: 14 Nov 2012 at 10:22am
Hi,
> Is there any way to remove Print_Area settings from Excel file?

Yes, print_area is just named range, and you can delete it like any other named range:
int PrintAreaIndex = xls.FindNamedRange(TXlsNamedRange.GetInternalName(InternalNameRange.Print_Area), xls.ActiveSheet);
xls.DeleteNamedRange(PrintAreaIndex);

>Is it possible to configure FlexCelAspViewer to show whole file regardles Print Area settings?

You can configure the range you want to show, but you will have to calculate it yourself. For example:
AspViewer.HtmlExport.PrintRangeLeft = 1;
AspViewer.HtmlExport.PrintRangeTop = 1;
AspViewer.HtmlExport.PrintRangeRight = xls.ColCount;
AspViewer.HtmlExport.PrintRangeBottom = xls.RowCount;

But note that if you do this, you might not get the full file. FlexCelAspViewer has a very complex algorithm to decide what to print, which includes using print_area if available (because that's what you normally want), but it also checks for many other things.

For example, if you have a file whose last cell is B15, but have an image going from A14 to C16, FlexCelAspViewer will use C16 as the last cell, while (RowCount,ColCount) will still be B15, because this is the last cell with data. Also, if you have an empty yellow column at say column D, FlexCelAspViewer will know it has to print D, because even if the column has no data, a user can see it because it is yellow. But if the column D has different width but the same color, FlexCelAspViewer will not include it, as the user can't see different widths.

For normal sheets, you can use this method 2). But in general, I would recommend to just remove the print area before exporting, because as explained, FlexCelAspViewer does a lot of work to ensure what it exports is what you want to export. (even if in this case it might be going a little too far, by including the print_area that you don't want, but that's the problem of "smart" algorithms).

Regards,
   Adrian.
Back to Top
Beketov Roman View Drop Down
New Member
New Member
Avatar

Joined: 21 Jul 2011
Posts: 22
Post Options Post Options   Quote Beketov Roman Quote  Post ReplyReply Direct Link To This Post Posted: 14 Nov 2012 at 11:07am
Thank you very much for the answer. 

Looks like the first method is OK. One thing: after I removed Print Area I still see the difference between RowCount and shown file. 
Back to Top
Adrian Gallero View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 1237
Post Options Post Options   Quote Adrian Gallero Quote  Post ReplyReply Direct Link To This Post Posted: 14 Nov 2012 at 11:18am
As said, FlexCelAspNetViewer (like any other exporting class in FlexCel) might not use the rowcount when deciding what to export, if for example you have an empty row at the end, it will count for RowCount, but FlexCelAspNewViewer knows that row has no data, and not show it. 

Are you not seeing the whole file after removing the print_area?  If so, maybe what happens is that print_area is a local name, you have one per sheet. In the code above I just removed the one in the active sheet:

int PrintAreaIndex = xls.FindNamedRange(TXlsNamedRange.GetInternalName(InternalNameRange.Print_Area), xls.ActiveSheet);

But you might want to remove them all:

for (int sheet = 1; sheet <=xls.SheetCount; sheet++)
{
int PrintAreaIndex = xls.FindNamedRange(TXlsNamedRange.GetInternalName(InternalNameRange.Print_Area), xls.ActiveSheet);

if (PrintAreaIndex >= 0) xls.DeleteNamedRange(PrintAreaIndex);
}
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down