My excel file got 3 sheets. When I convert all(3 sheets) at the same time, the second sheet's content is always unclear(low resolution). But when I only convert the second sheet, the content is very clear to see. Is this a bug or the way I'm doing it is wrong?
below is my code and step to reproduce the issue:
1. convert all sheet to image: fromPage = 0, untilPage=2
2. convert specific page: fromPage=1,untilPage=1
- Code: Select all
for (int i = fromPage; i < workbook.Worksheets.Count && i <= untilPage; i++)
{
Worksheet sheet = workbook.Worksheets[i];
if (!sheet.IsEmpty)
{
var target = path + Path.DirectorySeparatorChar + "Sheet_" + sheet.Name + "_Page_" + i.ToString();
var pngTarget = Path.ChangeExtension(target, "png");
using (MemoryStream ms = new MemoryStream())
{
sheet.ToEMFStream(ms, sheet.FirstRow, sheet.FirstColumn, sheet.LastRow, sheet.LastColumn);
Image image = Image.FromStream(ms);
Bitmap images = ResetResolutionExcel(image as Metafile, 300);
images.Save(pngTarget, ImageFormat.Png);
}
}
}
Here I also attached the sample file for testing