We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SheetRenderer does not keep bottom table border height if it is on the last row

Hello,


We have an excel table with a thick border. The bottom border is of different height than the top border if it is on the last row.

Run the attached code for the attached Test.xlsx with and without the “REMOVE TO TEST” cell
The bottom border height is different for the 2 cases

Sample Code:

var work = new Workbook(“Test.xlsx”);
var imageOptions = new ImageOrPrintOptions
{
Quality = 100,
VerticalResolution = 200,
HorizontalResolution = 200,
PrintingPage = PrintingPageType.IgnoreBlank,
ImageFormat = ImageFormat.Png,
OnePagePerSheet = true,
OnlyArea = true
};

var sheetRender = new SheetRender(work.Worksheets[0], imageOptions);
sheetRender.ToImage(0).Save(“test.bmp”);

Test.xlsx is attached.

Best regards,
Stefan Botan,
IBM Romania

Hi,


Thanks for the details and sample code.

Do you mean the height of the image is different in the two cases (one with “REMOVE TO TEST” cell text as in the Text.xlsx file and other by removing the text in the cell to re-save the file). I have tested your scenario and found you should specify the printable area set (dynamically) and set all the margins to zero to render the output image (having data/formattings) with least height and width for your needs. Please see the sample lines of code especially the lines in bold, I have added the lines to your code segment, it will give you the output image for both cases with same size for your needs:
e.g
Sample code:

var work = new Workbook(“e:\test2\Test.xlsx”);

Worksheet worksheet = work.Worksheets[0];
//You may specify it dynamically via Aspose.Cells APIs accordingly.
string printArea = string.Format(“A1:E6”);
worksheet.PageSetup.PrintArea = printArea;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
var imageOptions = new ImageOrPrintOptions
{
Quality = 100,
VerticalResolution = 200,
HorizontalResolution = 200,
PrintingPage = PrintingPageType.IgnoreBlank,
ImageFormat = ImageFormat.Png,
OnePagePerSheet = true,
OnlyArea = true
};

var sheetRender = new SheetRender(work.Worksheets[0], imageOptions);
sheetRender.ToImage(0).Save(“e:\test2\out1.bmp”);


Let us know if you still have any issue.

PS. Also please try our latest version/fix: Aspose.Cells for .NET v8.3.0.4

Thank you.

Hi,


Thanks for the help. Our issue is that if in you sample code use:
string printArea = string.Format(“A1:E4”);
and
string printArea = string.Format(“A1:E6”);

The bottom border of the table has different height.

Best regards,
Stefan Botan,
IBM Romania

Hi,


I observed the issue as you mentioned, the bottom border of the table has different height in the output image via Aspose.Cells APIs. I even tried to extend the margins a bit but it always renders the bottom border with less height as compared to top border height.
e.g
Sample code:

var work = new Workbook(“e:\test2\Test.xlsx”);

Worksheet worksheet = work.Worksheets[0];
//You may specify it dynamically
string printArea = string.Format(“A1:E4”);
worksheet.PageSetup.PrintArea = printArea;
worksheet.PageSetup.TopMargin = 0.1;
worksheet.PageSetup.LeftMargin = 0.1;
worksheet.PageSetup.RightMargin = 0.1;
worksheet.PageSetup.BottomMargin = 0.1;
var imageOptions = new ImageOrPrintOptions
{
Quality = 100,
VerticalResolution = 200,
HorizontalResolution = 200,
PrintingPage = PrintingPageType.IgnoreBlank,
ImageFormat = ImageFormat.Png,
OnePagePerSheet = true,
OnlyArea = true
};

var sheetRender = new SheetRender(work.Worksheets[0], imageOptions);
sheetRender.ToImage(0).Save(“e:\test2\out1.bmp”);

I have logged a ticket with an id “CELLSNET-43231” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,


We have evaluated your issue further.
We found, Aspose.Cells does work Ok and similar to what MS Excel built-in renderer for PDF does. For describing the problem more clearly, we simply set PrintArea to “A1:F4”, add a shape and enable the print gridlines in your source file (see the attached Test-2.xlsx file). Then we convert the “Test-2.xlsx” to PDF file format by Excel 2010. You will find that the thick border is beyond the cell in vertical direction. So when the thick border is the last row of the cell’s bottom border, the parts beyond the cells are cut off automatically. You’ll find this in the attached PDF file “Test-21.pdf” (generated by Excel 2010), the bottom thick border is also a little thinner as you may confirm it.

Thank you.