Hi,
Amjad,
Hi,
Amjad,
Hi Ung,
Thanks for your posting and using Aspose.Cells.
I tried the above code (518339) shared by Amjad and converted your file (Problem_SV_Regression_SmallSimplex_6.0EA_Dell_GA_Patch1_Build25.xlsx) into images and it converted the images fine. I have attached the output images for your reference.
Could you please provide us your file and let us know what issues you are facing. You can highlight your issues in a screenshot to clarify them. Also, let us know your sample code. We will look into it and help you asap.
Ok it looks like your conversion has split the last page with multiple rows into multiple pages. I was hoping to have this converted in just one long image if that’s possible. Either ways do share the settings or the code snippet that could get this converted properly without loss of data. You have used the correct file for conversion.
Hi ung,
Thanks for your posting and using Aspose.Cells.
If you could set the Print Area to “A1:S120”, then you can print your entire worksheet as image. Please see the following code. I have attached the output image which is single image containing all of the rows.
Java
String filePath = “F:\Shak-Data-RW\Downloads\Problem_SV_Regression_SmallSimplex_6.0EA_Dell_GA_Patch1_Build25.xlsx”;
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.getWorksheets().get(“SV_Regression_CallP”);
//Set its print area
worksheet.getPageSetup().setPrintArea(“A1:S120”);
//Now print the entire worksheet.
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.setOnePagePerSheet(true);
SheetRender sr = new SheetRender(worksheet, opts);
sr.toImage(0, filePath + “out_.png”);
Thanks Shakeel,
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.setOnePagePerSheet(true);
Hi Ung,
- You can make the PrintArea of a given Worksheet dynamic by using the Cells.getMaxDataRow & Cells.getMaxDataColumn methods. Please note, aforesaid methods will return the indexes of row and column on the Worksheet that contains data (not null). You can further use the CellsHelper.columnIndexToName method to determine the column name to be used as PrintArea parameter.
- You can use the ImageOrPrintOptions.setAllColumnsInOnePagePerSheet method to fit all columns of a Worksheet on a single image.
Workbook book = new Workbook(myDir + “sample.xlsx”);
Worksheet sheet = book.getWorksheets().get(0);
Cells cells = sheet.getCells();
int MaxDataRow = cells.getMaxDataRow() + 1;
int MaxDataColumn = cells.getMaxDataColumn();
String MaxDataColumnName = CellsHelper.columnIndexToName(MaxDataColumn);
sheet.getPageSetup().setPrintArea(“A1:” + MaxDataColumnName + MaxDataRow);
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageFormat(ImageFormat.getBmp());
options.setAllColumnsInOnePagePerSheet(true);
SheetRender render = new SheetRender(sheet, options);
render.toImage(0, myDir + “output.bmp”);
Thanks,
Hi Ung,
Please find the converter code attached. I would like to be able to convert both the included files with the same code. Its the first file that throws the exception.
Hi,
String maxDataColumnName = CellsHelper.columnIndexToName(maxCols);
int maxCols = cells.getMaxDataColumn(); int maxRows = cells.getMaxDataRow() + 1; System.out.println("maxCols: " +maxCols+ ", maxRows: "+maxRows); String maxDataColumnName = CellsHelper.columnIndexToName(maxCols); //... }