Adding a new picture to existing sheet in Java

Hi,

I'm trying to assess Aspose and POI for Excel manipulation, and I encountered a picture resizing problem using Aspose.

I have an existing sheet with an image, and I'm trying to add a new image to the sheet (at a different location). I simply did:

sheet.getShapes().addPicture(1, 5, fileName)

when I saved the workbook, the old picture was stretched. Is this a common problem in Aspose? Was there anything that I overlooked?

I attached my template file with the old image.

Thank you in advance.

Cathy Liu

Hi,

Thanks for providing us the template Excel file.

I have tested your case with your
template Excel file and I can find the issue. I have used a sample
picture to insert it into the first worksheet at some other location (as you pointed out).
The picture is inserted but it stretches the existing image in that
sheet too.


I have logged your issue with an id: CELLSJAVA-26508. We will fix it soon.

Thank you.

Hi,

We have fixed the issue of picture’s size and position. Please download Aspose.Cells for Java v2.5.2.17.

Thank you very much

Hello,

I used the attached jar file and the stretched image problem for that template have been fixed, but the new jar file introduced a new problem: I got bold outlines for all the textboxes.

Please see my attached Excel template. I simply inserted a new picture at 0,1 then saved the Workbook, and the output file contained bold outlines around all the textboxes.

Please kindly advise.

Thank you again.


Cathy

Hi,

I tested Aspose.Cells for Java v2.5.2.17. on multiple templates, but unfortunately graphical elements such as chart title have been shifted using this new jar. Such elements were perfectly fine using the aspose-cells-2.5.1.jar

Please kindly advice again.

Thank you very much.


Cathy Liu


Hi Cathy Liu,

For:
"…but the new jar file introduced a new problem: I got bold outlines for all the textboxes. "
Yes, we noticed this issue, I have reopened your issue again and will figure it out soon.

For:
"but unfortunately graphical elements such as chart title have been shifted using this new jar."
Could you give us your template and output files with sample code to show the issue, we will check it soon.

Thank you.

Thank you very much for the quick response. My template is named HistoryCapSide.xlsx and the output file is named output.xlsx. The images are on the cover sheet and the graph is on the Report sheet.

below is my code:

private static void try3() throws Exception{
fileName = “C:\temp\HistorySideCap.xlsx”;
Workbook workbook = new Workbook();
workbook.open(fileName);
Worksheets worksheets = workbook.getWorksheets();

for (int i = 0; i < worksheets.size(); i++){
Worksheet ws = worksheets.getSheet(i);
if (ws.getName().equalsIgnoreCase(“DataSheet”)){
populateTry3(ws);
}
if (ws.getName().equalsIgnoreCase(“cover”)){
processImage(ws);
}
}

workbook.calculateFormula();
workbook.save(outputFileName);
}

private static void populateTry3(Worksheet ws){
Cell c = ws.getCells().getCell(2, 1);
c.setValue(67.5);
c = ws.getCells().getCell(2, 2);
c.setValue(89.05);
c = ws.getCells().getCell(2, 3);
c.setValue(70.5);
c = ws.getCells().getCell(2, 4);
c.setValue(-7.5);
c = ws.getCells().getCell(2, 5);
c.setValue(0.375);
c = ws.getCells().getCell(2, 6);
c.setValue(0);
c = ws.getCells().getCell(2, 7);
c.setValue(30.004);
c = ws.getCells().getCell(2, 8);
c.setValue(29);

c = ws.getCells().getCell(3, 1);
c.setValue(-17.5);
c = ws.getCells().getCell(3, 2);
c.setValue(0.95);
c = ws.getCells().getCell(3, 3);
c.setValue(-10.75);
c = ws.getCells().getCell(3, 4);
c.setValue(13);
c = ws.getCells().getCell(3, 5);
c.setValue(13);
c = ws.getCells().getCell(3, 6);
c.setValue(13);
c = ws.getCells().getCell(3, 7);
c.setValue(13);
c = ws.getCells().getCell(3, 8);
c.setValue(13);

c = ws.getCells().getCell(5, 1);
c.setValue(-146.5);
c = ws.getCells().getCell(5, 2);
c.setValue(-80);
c = ws.getCells().getCell(5, 3);
c.setValue(-109.75);
c = ws.getCells().getCell(5, 4);
c.setValue(13.9);
c = ws.getCells().getCell(5, 5);
c.setValue(13.9);
c = ws.getCells().getCell(5, 6);
c.setValue(13.9);
c = ws.getCells().getCell(5, 7);
c.setValue(13.9);
c = ws.getCells().getCell(5, 8);
c.setValue(13.9);
}

private static void processImage(Worksheet sheet){

Picture picture2 = sheet.getShapes().addPicture(1, 1,
"C:\Documents and Settings\liuc01\My Documents\My Pictures\footer.JPG ", 100, 100);
}

Hi,

Thanks for providing us the sample code and template files.

I am able to find this issue as well, we will also figure this issue out with your other issues.

Thank you.

Hi,

Has there been any update on this issue?


Thanks,

Cathy

Hi,

I am afraid, there is no update yet. But I have forwarded your request.

Hi,


We have fixed the issue of TextBox in our latest release of Aspose.Cells JAVA v2.5.3.2. Please try it and share your feedback with us.
For the issue of Chart Title, I am afraid we cannot fix it very soon cause of its complexity.
Thank you for understanding.