@Neha_Gautam
The efficient way is just set a proper print area, then render to image:
String worksheetName = "Sheet1";
String tableName = "Table1";
Workbook workbook = new Workbook("test.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(worksheetName);
ListObject table = worksheet.getListObjects().get(tableName);
//set print area to output
String leftTopCellName = CellsHelper.cellIndexToName(table.getStartRow(), table.getStartColumn());
String rightBottomCellName = CellsHelper.cellIndexToName(table.getEndRow(), table.getEndColumn());
worksheet.getPageSetup().setPrintArea(leftTopCellName + ":" + rightBottomCellName);
worksheet.getPageSetup().setTopMargin(0);
worksheet.getPageSetup().setBottomMargin(0);
worksheet.getPageSetup().setRightMargin(0);
worksheet.getPageSetup().setLeftMargin(0);
ImageOrPrintOptions imgOptionsForTable = new ImageOrPrintOptions();
imgOptionsForTable.setImageType(ImageType.JPEG);
imgOptionsForTable.setHorizontalResolution(600);
imgOptionsForTable.setVerticalResolution(600);
imgOptionsForTable.setOnePagePerSheet(true);
imgOptionsForTable.setOnlyArea(true);
SheetRender sr = new SheetRender(worksheet, imgOptionsForTable);
sr.toImage(0, output.jpg);
If you still want to use copy to a new workbook, and then render to image, you should also copy theme.
...
Workbook newWorkbook = new Workbook(FileFormatType.XLSX);
//copy theme
newWorkbook.copyTheme(workbook);
newWorkbook.setDefaultStyle(sourceRange.getWorksheet().getWorkbook().getDefaultStyle());
...