We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Getting Colour Palette For Table

Hi ,


Is there a way to get Colour palette for setting background of a table in Java.

P.S. we are evaluating Aspose slides and any help regarding this would be appreciated.

Thanks
Ashok

Hi Ashok,

Thanks for inquiring Aspose.Slides.

I have observed your requirements and like to share you need to set the table color by accessing individual cells belonging to rows of table and setting the color for cell. Please try using following sample code on your end to serve the purpose.

public static void FillTable()
{
Presentation pres=new Presentation();
ISlide slide=pres.getSlides().get_Item(0);

// Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30, 30 };
// Add table shape to slide
ITable tbl = slide.getShapes().addTable(100, 50, dblCols, dblRows);

// Set border format for each cell
for (int row = 0; row < tbl.getRows().size(); row++)
{
for (int cell = 0; cell < tbl.getRows().get_Item(row).size(); cell++)
{
tbl.getRows().get_Item(row).get_Item(cell).getFillFormat().setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getFillFormat().getSolidFillColor().setColor(Color.RED);
}
}

// Save PPTX to Disk
pres.save(“C:\Aspose Data\table.pptx”, SaveFormat.Pptx);
}

Many Thanks,