options.ImageType = ImageType.Jpeg; the code and output image is OK
but if you apply data filter on the sheet[hide some rows] , you will get a worng row Height in output image
Please share your source and output files so that we can investigate it on our end and help you accordingly.
code.zip (5.8 MB)
I also upload an mp4 int the zip, you can see the wrong row height and worksheet.AutoFitRows() will show the hide rows
Thanks for the sample code, sample video and template file.
Please update your code as following, it will work fine as I tested:
var workbook = new Workbook(“fail_detail_statistics___sms__2018-07-11_.xlsx”);
Worksheet worksheet = workbook.Worksheets;
// Set the print area with your desired range
// Set all margins as 0
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
worksheet.AutoFilter.Custom(0, FilterOperatorType.Equal, 3);
AutoFitterOptions autofitterOptions = new AutoFitterOptions();
autofitterOptions.IgnoreHidden = true;
// Set OnePagePerSheet option as true ImageOrPrintOptions options = new ImageOrPrintOptions(); options.OnePagePerSheet = true; options.ImageType = ImageType.Jpeg; options.HorizontalResolution = 100; options.VerticalResolution = 100; // Take the image of your worksheet SheetRender sr = new SheetRender(worksheet, options); sr.ToImage(0, "ww.jpg"); workbook.Save("123.xlsx"); Process.Start("ww.jpg");
Let us know if you still find any issue.
yes， do you see the wrong row height in image
Could you try my sample code and provide the output image file here, we will check it soon. Also, give us screenshot with details which wrong row height you are talking about?