We use Spire.XLS to generate screenshots of excel files and I want to make improvements to the screenshot process.
Is it possible to get the active selected range from the excel file?
I would then be able to calculate the firstRow, firstColumn, lastRow and lastColumn.
Thank you in advance.
I attached an excel file with an active selection.
Below you can find the code we use to generate the screenshot.
- Code: Select all
using (Workbook workbook = new Workbook())
{
workbook.LoadFromFile(filePath);
using (Worksheet sheet = workbook.Worksheets[workbook.ActiveSheetIndex]) {
sheet.PageSetup.IsPrintGridlines = true;
sheet.PageSetup.BottomMargin = 0;
sheet.PageSetup.LeftMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.TopMargin = 0;
using (var image = sheet.ToImage(1, 1, 30, 15)) {
image.Save(stream, ImageFormat.Png);
getHeapSizeAfter();
}
}
}
Best,
Erick