In an asp.net 6 mvc application, I am capturing images of the excel from its print area. When migrating from version 13.12.0 to 14.3.3 I see that the width of the captured area is different (801 pixels in 13.12.0 and 861 pixels in 14.3.3). In my code I am setting the margins in PageSetup to 0. Why is there this difference and how can I ensure the same width?
- Code: Select all
var sheet = workbook.Worksheets[sheetNameFinal];
if (sheet == null || sheet.PageSetup.PrintArea == null)
{
return new List<byte[]>();
}
sheet.PageSetup.LeftMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.BottomMargin = 0;
sheet.PageSetup.TopMargin = 0;
var printArea = sheet.PageSetup.PrintArea;
var ranges = sheet.PageSetup.PrintArea.Split(',').ToList();
var result = new List<byte[]>();
foreach (var range in ranges)
{
var cellRange = sheet.Range[range];
AnyBitmap image = sheet.ToImage(cellRange.Row, cellRange.Column, cellRange.LastRow, cellRange.LastColumn);
var content = image.ExportBytes(AnyBitmap.ImageFormat.Png);
result.Add(content);
}
Regards,
Carlos