Hi Team,
Team,
When i tried to add watermark to an excel file of size 1.2 MB I am getting out of memory exception
Hi Team,
Hi Surabhi,
Workbook workbook = new Workbook(“D:/Input_watermark.xlsx”);
int sheets = workbook.getWorksheets().getCount();
System.out.println(“Number of sheets—>”+sheets);
for(int count=0;count<sheets;count++)
{
Worksheet sheet = workbook.getWorksheets().get(count);
System.out.println(“GOT Worksheet”);
//Add Watermark
Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1,
“cognizant”, “Arial Black”, 50, false, true
, 18, 8, 1, 1, 130, 800);
//Get the fill format of the word art
MsoFillFormat wordArtFormat = wordart.getFillFormat();
//Set the color
wordArtFormat.setForeColor(Color.getRed());
//Set the transparency
wordArtFormat.setTransparency(0.9);
//Make the line invisible
MsoLineFormat lineFormat = wordart.getLineFormat();
lineFormat.setVisible(false);
//Lock Shape Aspects
wordart.setLocked(true);
wordart.setLockedProperty(ShapeLockType.SELECTION, true);
wordart.setLockedProperty(ShapeLockType.SHAPE_TYPE, true);
wordart.setLockedProperty(ShapeLockType.MOVE, true);
wordart.setLockedProperty(ShapeLockType.RESIZE, true);
wordart.setLockedProperty(ShapeLockType.TEXT, true);
}
//Save the file
workbook.save(“D:/output.xlsx”);
sbalumsc:
Hi Team,Please find attached excel file which I am trying to watermark and I am getting below exceptionException in thread "main" java.lang.OutOfMemoryError: Java heap spaceat com.aspose.cells.zamn.a(Unknown Source)at com.aspose.cells.zaco.a(Unknown Source)at com.aspose.cells.zacn.b(Unknown Source)at com.aspose.cells.zadb.z(Unknown Source)at com.aspose.cells.zadb.a(Unknown Source)at com.aspose.cells.zada.a(Unknown Source)at com.aspose.cells.Workbook.a(Unknown Source)at com.aspose.cells.Workbook.a(Unknown Source)at com.aspose.cells.Workbook.(Unknown Source)at com.word.CreateExcelFileWithWaterMark.main(CreateExcelFileWithWaterMark.java:18)