I have a table in pptx with a few cells filled in. I replace cells in the table and the one that was empty from the beginning loses the font and size information. The cells that had text from the start are replaces correctly.
Hi Hasse,
Thanks for your interest in Aspose.Slides.
I have observed the sample code shared by you and like to share that you are setting the text on text frame level. When you do so, you are resetting the text to default formatting. In order to retain the text formatting, you need to set the text on portion level. Please visit this documentation link for your kind reference in this regard as well. I have shared the modified code sample for your reference as well.
Many Thanks,
The supplied code doesn’t fix the problem. I have attached the output I get. Don’t you get the same?
Hi Hasse,
I have observed the PDF. The issue is not related to Aspose.Slides. The cells for which there is no text in the cells there is no formatting information. If those cells have been filled with the the sample text with desired formatting like first and last cell, then they must have adhered to formatting. Since there is no formatting information for them, they are therefore rendered with default formatting. There are two possible solutions. The easier one is to fill all cells with some sample text by using desired formatting. When you will set the text for that portion, Aspose.Slides will adhere to source formatting. The other option is to copy the formatting of one of cells that is already added with your desired formatting (In your case its first and last cell) and set that for rest of portions where desired formatting information is unavailable. You can use Paragraph and portion copying mechanism in this regard to serve the purpose. Please visit this documentation link for your kind reference in this regard.
Many Thanks,
Thanks for the explanation but this is still not 100% correct. The first cell has both the new and the old text in it (should be cell_0_0 and not containing the 12). Please see the former attachment. This was not how it was before, but is this how it works from now on?
Hi Hasse,
public static void testTableText(){System.out.println(“os.name=” + System.getProperty(“os.name”));System.out.println(“os.version=” + System.getProperty(“os.version”));System.out.println(“java.version=” + System.getProperty(“java.version”));Presentation presentation = new Presentation(path+“Aspose_15_test.pptx”);presentation.joinPortionsWithSameFormatting();ISlide slide1 = presentation.getSlides().get_Item(0);for (int i = 0; i < slide1.getShapes().size(); i++) {IShape shape = slide1.getShapes().get_Item(i);if (shape.getName().equals(“MainTable”)) {ITable table = (ITable)shape;int portionCount=table.get_Item(0, 0).getTextFrame().getParagraphs().get_Item(0).getPortions().getCount();if(portionCount>1)for(int j=1;j<portionCount;j++)table.get_Item(0, 0).getTextFrame().getParagraphs().get_Item(0).getPortions().removeAt(1);table.get_Item(0, 0).getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Cell_0_0”);table.get_Item(1, 1).getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Cell_1_1”);table.get_Item(2, 2).getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Cell_2_2”);table.get_Item(3, 3).getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Cell_3_3”);table.get_Item(4, 4).getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Cell_4_4”);table.get_Item(5, 5).getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Cell_5_5”);table.get_Item(6, 6).getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Cell_6_6”);}}presentation.save(“slides.pdf”, SaveFormat.Pdf);System.out.println(new java.util.Date());}
Per your recommendation I have attached an example solution. Could you please have a look?
Hi Hasse,
I am sorry, I did not get your point. I have shared the sample code with you that is addressing the issue of 12 being displayed on cell_0_0. Is there some thing else that I may help you with. Can you please share is there any issue with sample code that you have shared in your last post. I also recommend you to please give a try to my sample code in my last post.
Many Thanks,