Free Support Forum - aspose.com

Borders missing on right and bottom of image when using sheetRender.ToImage() method

When I use the attached test code, the borders are cut off of the image on the right side and at the bottom. I have tried playing with the settings but can't seem to get the borders to display properly.

Hi,

Please see this code below, I have inserted my own code inside your code. Please see the output image, now has all the borders.

I have kept the code generic and it should run for all types of sheets. Hopefully, it will be helpful for you and other people.

C#


string filePath = @“F:\Downloads\AsposeMissingBorders\AsposeMissingBorders\Book1.xls”;


Workbook wb = new Workbook(filePath);

Worksheet ws = wb.Worksheets[“MyTestSheet”];


//Get the last cell

Cell lastCell = ws.Cells.LastCell;


//If last cell is merged then calculate last cell again

if (lastCell.IsMerged)

{

Range rng = lastCell.GetMergedRange();


int idxCol = lastCell.Column + rng.ColumnCount;

int idxRow = lastCell.Row + rng.RowCount;


string mycell = CellsHelper.CellIndexToName(idxRow, idxCol);


lastCell = ws.Cells[mycell];

}


//Set the width and height of the last row and column


//Set its width 0.5 before taking a print

double oldWidth = ws.Cells.Columns[lastCell.Column].Width;

ws.Cells.Columns[lastCell.Column].Width = 0.5;


//Set its width 0.5 before taking a print

double oldHeight = ws.Cells.Rows[lastCell.Row].Height;

ws.Cells.Rows[lastCell.Row].Height = 0.5;


//Assign the print area

PageSetup pgSetup = ws.PageSetup;

pgSetup.PrintArea = “A1:” + lastCell.Name;


//Set the margins to remove white spacing

pgSetup.LeftMargin = 0;

pgSetup.RightMargin = 0;

pgSetup.TopMargin = 0;

pgSetup.BottomMargin = 0;


//Your code

ImageOrPrintOptions options = new ImageOrPrintOptions() { PrintingPage = PrintingPageType.Default, IsImageFitToPage = true, OnePagePerSheet = true };

SheetRender sheetRender = new SheetRender(ws, options);


//Save the image in jpeg format to reduce size

Bitmap bm = sheetRender.ToImage(0);

bm.Save(filePath + “SheetImage.jpg”, ImageFormat.Jpeg);
Output Image:

I'm upgrading from version 4.8.2.4 of Aspose.Cells and am having several issues that weren't there before. In my opinion, this issue needs to be fixed in Aspose.Cells and not in my code. I tried your solution, which I had already found in the forum, and it doesn't work in all cases. Try running the test code against the attached workbook. The cells in the last row aren't merged so the whole column gets it's width changed.

Hi,

This issue has been logged as CELLSNET-27687.

Hi,

We have fixed this issue. Please download Aspose.Cells for .NET v5.3.3.2

This is better but still not working like before. In our code, we use worksheet.AutoFitRows(). When this method is used, the borders are still cut off. Attached is an example.

Hi,

Thanks for your feedback and the files. We will check it soon and update you asap.

Hi,


Thanks for your project. We can see that the lower border is still missing in output image. We have attached your comments and the source code to the ticket associated with this thread. Also, we have re-opened the ticket. Soon we will update you on this matter.

Hi,

We have fixed this issue. Please download Aspose.Cells for .NET v5.3.3.3.

This addressed most of the issues. The remaining issue is that when paging, the border is cut off on the right hand side on all pages after the first page. Attached is sample code that demonstrates this.

Hi,


Thank you for your feedback and the project.
We can see the issue as mentioned by you in your last post and we have attached your comments to the ticket associated with this thread. Also, we have re-opened this ticket. Hopefully soon we will get back to you on this.

Hi,

We have fixed this issue. Please download Aspose.Cells for .NET 5.3.3.4

The issues you have found earlier (filed as 27687) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan