public class TimelineCollection extends CollectionBase
Example
Workbook book = new Workbook();
Worksheet sheet = book.getWorksheets().get(0);
Cells cells = sheet.getCells();
cells.get(0, 0).setValue("fruit");
cells.get(1, 0).setValue("grape");
cells.get(2, 0).setValue("blueberry");
cells.get(3, 0).setValue("kiwi");
cells.get(4, 0).setValue("cherry");
//Create date style
Style dateStyle = new CellsFactory().createStyle();
dateStyle.setCustom("m/d/yyyy");
cells.get(0, 1).setValue("date");
cells.get(1, 1).setValue(new DateTime(2021, 2, 5));
cells.get(2, 1).setValue(new DateTime(2022, 3, 8));
cells.get(3, 1).setValue(new DateTime(2023, 4, 10));
cells.get(4, 1).setValue(new DateTime(2024, 5, 16));
//Set date style
cells.get(1, 1).setStyle(dateStyle);
cells.get(2, 1).setStyle(dateStyle);
cells.get(3, 1).setStyle(dateStyle);
cells.get(4, 1).setStyle(dateStyle);
cells.get(0, 2).setValue("amount");
cells.get(1, 2).setValue(50);
cells.get(2, 2).setValue(60);
cells.get(3, 2).setValue(70);
cells.get(4, 2).setValue(80);
PivotTableCollection pivots = sheet.getPivotTables();
//Add a PivotTable
int pivotIndex = pivots.add("=Sheet1!A1:C5", "A12", "TestPivotTable");
PivotTable pivot = pivots.get(pivotIndex);
pivot.addFieldToArea(PivotFieldType.ROW, "fruit");
pivot.addFieldToArea(PivotFieldType.COLUMN, "date");
pivot.addFieldToArea(PivotFieldType.DATA, "amount");
pivot.setPivotTableStyleType(PivotTableStyleType.PIVOT_TABLE_STYLE_MEDIUM_10);
//Refresh PivotTable data
pivot.refreshData();
pivot.calculateData();
//do your business
book.save("out.xlsx");
| Modifier and Type | Method and Description |
|---|---|
int |
add(PivotTable pivot,
int row,
int column,
int baseFieldIndex)
Add a new Timeline using PivotTable as data source
|
int |
add(PivotTable pivot,
int row,
int column,
PivotField baseField)
Add a new Timeline using PivotTable as data source
|
int |
add(PivotTable pivot,
int row,
int column,
java.lang.String baseFieldName)
Add a new Timeline using PivotTable as data source
|
int |
add(PivotTable pivot,
java.lang.String destCellName,
int baseFieldIndex)
Add a new Timeline using PivotTable as data source
|
int |
add(PivotTable pivot,
java.lang.String destCellName,
PivotField baseField)
Add a new Timeline using PivotTable as data source
|
int |
add(PivotTable pivot,
java.lang.String destCellName,
java.lang.String baseFieldName)
Add a new Timeline using PivotTable as data source
|
Timeline |
get(int index)
Gets the Timeline by index.
|
Timeline |
get(java.lang.String name)
Gets the Timeline by Timeline's name.
|
public Timeline get(int index)
Example
//Get the Timeline by index.
Timeline objByIndex = sheet.getTimelines().get(0);
get in class CollectionBaseindex - Specified position index.public Timeline get(java.lang.String name)
Example
//Get the Timeline by Timeline's name.
Timeline objByName = sheet.getTimelines().get("date");
public int add(PivotTable pivot, int row, int column, java.lang.String baseFieldName)
Example
//Add a new Timeline using PivotTable as data source
sheet.getTimelines().add(pivot, 10, 5, "date");
pivot - PivotTable objectrow - Row index of the cell in the upper-left corner of the Timeline range.column - Column index of the cell in the upper-left corner of the Timeline range.baseFieldName - The name of PivotField in PivotTable.BaseFieldspublic int add(PivotTable pivot, java.lang.String destCellName, java.lang.String baseFieldName)
Example
//Add a new Timeline using PivotTable as data source
sheet.getTimelines().add(pivot, "i15", "date");
pivot - PivotTable objectdestCellName - The cell name in the upper-left corner of the Timeline range.baseFieldName - The name of PivotField in PivotTable.BaseFieldspublic int add(PivotTable pivot, int row, int column, int baseFieldIndex)
Example
//Add a new Timeline using PivotTable as data source
sheet.getTimelines().add(pivot, 15, 5, 1);
pivot - PivotTable objectrow - Row index of the cell in the upper-left corner of the Timeline range.column - Column index of the cell in the upper-left corner of the Timeline range.baseFieldIndex - The index of PivotField in PivotTable.BaseFieldspublic int add(PivotTable pivot, java.lang.String destCellName, int baseFieldIndex)
Example
//Add a new Timeline using PivotTable as data source
sheet.getTimelines().add(pivot, "i5", 1);
pivot - PivotTable objectdestCellName - The cell name in the upper-left corner of the Timeline range.baseFieldIndex - The index of PivotField in PivotTable.BaseFieldspublic int add(PivotTable pivot, int row, int column, PivotField baseField)
Example
//Add a new Timeline using PivotTable as data source
sheet.getTimelines().add(pivot, 20, 5, pivot.getBaseFields().get(1));
pivot - PivotTable objectrow - Row index of the cell in the upper-left corner of the Timeline range.column - Column index of the cell in the upper-left corner of the Timeline range.baseField - The PivotField in PivotTable.BaseFieldspublic int add(PivotTable pivot, java.lang.String destCellName, PivotField baseField)
Example
//Add a new Timeline using PivotTable as data source
sheet.getTimelines().add(pivot, "i10", pivot.getBaseFields().get(1));
pivot - PivotTable objectdestCellName - The cell name in the upper-left corner of the Timeline range.baseField - The PivotField in PivotTable.BaseFieldsSee Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.