Public API Changements dans Aspose.Cells 8.5.2

API ajoutées

Rendre la feuille de calcul dans le contexte graphique

Cette version de Aspose.Cells for Java API a exposé une autre surcharge de la méthode SheetRender.toImage qui permet désormais d’accepter une instance de la classe Graphics2D pourrendre la feuille de calcul dans le contexte graphique. Les signatures de la méthode nouvellement ajoutée sont les suivantes.

  • SheetRender.toImage(int pageIndex, graphique Graphics2D)

Voici le scénario d’utilisation simple.

Java

 //Create workbook object from source file

Workbook workbook = new Workbook("source.xlsx");

//Access first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);

//Create empty image and fill it with blue color

int width = 800;

int height = 800;

BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

Graphics2D g = image.createGraphics();

g.setColor(java.awt.Color.blue);

g.fillRect(0, 0, width, height);

//Set one page per sheet to true in image or print options

ImageOrPrintOptions opts = new ImageOrPrintOptions();

opts.setOnePagePerSheet(true);

//Render worksheet to graphics context

SheetRender sr = new SheetRender(worksheet, opts);

sr.toImage(0, g);

//Save the graphics context image in Png format

File outputfile = new File("test.png");

ImageIO.write(image, "png", outputfile);

Méthode PivotTable.getCellByDisplayName ajoutée

Aspose.Cells for Java 8.5.2 a exposé la méthode PivotTable.getCellByDisplayName qui peut être utilisée pourrécupérer l’objet Cell par le nom du PivotField. Cette méthode peut être utile dans les scénarios où vous souhaitez mettre en surbrillance ou formater l’en-tête PivotField.

Voici le scénario d’utilisation simple.

Java

 //Create workbook object from source excel file

Workbook workbook = new Workbook("source.xlsx");

//Access first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);

//Access first pivot table inside the worksheet

PivotTable pivotTable = worksheet.getPivotTables().get(0);

//Access cell by display name of 2nd data field of the pivot table

String displayName = pivotTable.getDataFields().get(1).getDisplayName();

Cell cell = pivotTable.getCellByDisplayName(displayName);

//Access cell style and set its fill color and font color

Style style = cell.getStyle();

style.setForegroundColor(Color.getLightBlue());

style.getFont().setColor(Color.getBlack());

//Set the style of the cell

pivotTable.format(cell.getRow(), cell.getColumn(), style);

//Save workbook

workbook.save("output.xlsx");

Propriété SaveOptions.MergeAreas ajoutée

Aspose.Cells for Java 8.5.2 a exposé la propriété SaveOptions.MergeAreas qui peut accepter une valeur de type booléen. La valeur par défaut est false cependant, si elle est définie sur true, le Aspose.Cells for Java API essaie de fusionner la CellArea individuelle avant d’enregistrer le fichier.

Propriété Geometry.ShapeAdjustValues ajoutée

Avec la version v8.5.2, le Aspose.Cells API a exposé la méthode Geometry.getShapeAdjustValues qui peut être utilisée pouraccéder et modifier les points de réglage de différentes formes.

Par exemple,

  1. Le rectangle arrondi a un ajustement pour changer l’arc
  2. Triangle a un ajustement pour changer l’emplacement du point
  3. Le trapèze a un ajustement pour changer la largeur du haut
  4. Les flèches ont deux ajustements pour changer la forme de la tête et de la queue

Voici le scénario d’utilisation le plus simple.

Java

 //Create workbook object from source excel file

Workbook workbook = new Workbook("source.xlsx");

//Access first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);

//Access first three shapes of the worksheet

Shape shape1 = worksheet.getShapes().get(0);

Shape shape2 = worksheet.getShapes().get(1);

Shape shape3 = worksheet.getShapes().get(2);

//Change the adjustment values of the shapes

shape1.getGeometry().getShapeAdjustValues().get(0).setValue(0.5d);

shape2.getGeometry().getShapeAdjustValues().get(0).setValue(0.8d);

shape3.getGeometry().getShapeAdjustValues().get(0).setValue(0.5d);

//Save the workbook

workbook.save("output.xlsx");

Champ d’énumération ConsolidationFunction.DISTINCT_COUNT ajouté

Aspose.Cells for Java 8.5.2 a exposé le champ ConsolidationFunction.DISTINCT_COUNT qui peut être utilisé pour appliquer la fonction consolidée Distinct Count sur DataField d’un tableau croisé dynamique.