TimelineCollection

Inheritance: java.lang.Object, com.aspose.cells.CollectionBase

public class TimelineCollection extends CollectionBase

Specifies the collection of all the Timeline objects on the specified worksheet. Due to MS Excel, Excel 2003 does not support Timeline.

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");

Methods

MethodDescription
add(PivotTable pivot, int row, int column, PivotField baseField)Add a new Timeline using PivotTable as data source
add(PivotTable pivot, int row, int column, int baseFieldIndex)Add a new Timeline using PivotTable as data source
add(PivotTable pivot, int row, int column, String baseFieldName)Add a new Timeline using PivotTable as data source
add(PivotTable pivot, String destCellName, PivotField baseField)Add a new Timeline using PivotTable as data source
add(PivotTable pivot, String destCellName, int baseFieldIndex)Add a new Timeline using PivotTable as data source
add(PivotTable pivot, String destCellName, String baseFieldName)Add a new Timeline using PivotTable as data source
add(Object o)Adds an item to the CollectionBase instance.
clear()Removes all objects from the CollectionBase instance.
contains(Object o)Return whether instance contains this object
equals(Object arg0)
get(int index)Gets the Timeline by index.
get(String name)Gets the Timeline by Timeline’s name.
getClass()
getCount()Gets the number of elements contained in the CollectionBase instance.
hashCode()
indexOf(Object o)Determines the index of a specific item in the CollectionBase instance.
iterator()Returns an enumerator that iterates through the CollectionBase instance.
notify()
notifyAll()
removeAt(int index)Removes the item at the specified index.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

add(PivotTable pivot, int row, int column, PivotField baseField)

public int add(PivotTable pivot, int row, int column, PivotField baseField)

Add a new Timeline using PivotTable as data source

Example

         //Add a new Timeline using PivotTable as data source
         sheet.getTimelines().add(pivot, 20, 5, pivot.getBaseFields().get(1));

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
rowintRow index of the cell in the upper-left corner of the Timeline range.
columnintColumn index of the cell in the upper-left corner of the Timeline range.
baseFieldPivotFieldThe PivotField in PivotTable.BaseFields

Returns: int - The new add Timeline index

add(PivotTable pivot, int row, int column, int baseFieldIndex)

public int add(PivotTable pivot, int row, int column, int baseFieldIndex)

Add a new Timeline using PivotTable as data source

Example

         //Add a new Timeline using PivotTable as data source
         sheet.getTimelines().add(pivot, 15, 5, 1);

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
rowintRow index of the cell in the upper-left corner of the Timeline range.
columnintColumn index of the cell in the upper-left corner of the Timeline range.
baseFieldIndexintThe index of PivotField in PivotTable.BaseFields

Returns: int - The new add Timeline index

add(PivotTable pivot, int row, int column, String baseFieldName)

public int add(PivotTable pivot, int row, int column, String baseFieldName)

Add a new Timeline using PivotTable as data source

Example

         //Add a new Timeline using PivotTable as data source
         sheet.getTimelines().add(pivot, 10, 5, "date");

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
rowintRow index of the cell in the upper-left corner of the Timeline range.
columnintColumn index of the cell in the upper-left corner of the Timeline range.
baseFieldNamejava.lang.StringThe name of PivotField in PivotTable.BaseFields

Returns: int - The new add Timeline index

add(PivotTable pivot, String destCellName, PivotField baseField)

public int add(PivotTable pivot, String destCellName, PivotField baseField)

Add a new Timeline using PivotTable as data source

Example

         //Add a new Timeline using PivotTable as data source
         sheet.getTimelines().add(pivot, "i10", pivot.getBaseFields().get(1));

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
destCellNamejava.lang.StringThe cell name in the upper-left corner of the Timeline range.
baseFieldPivotFieldThe PivotField in PivotTable.BaseFields

Returns: int - The new add Timeline index

add(PivotTable pivot, String destCellName, int baseFieldIndex)

public int add(PivotTable pivot, String destCellName, int baseFieldIndex)

Add a new Timeline using PivotTable as data source

Example

         //Add a new Timeline using PivotTable as data source
         sheet.getTimelines().add(pivot, "i5", 1);

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
destCellNamejava.lang.StringThe cell name in the upper-left corner of the Timeline range.
baseFieldIndexintThe index of PivotField in PivotTable.BaseFields

Returns: int - The new add Timeline index

add(PivotTable pivot, String destCellName, String baseFieldName)

public int add(PivotTable pivot, String destCellName, String baseFieldName)

Add a new Timeline using PivotTable as data source

Example

         //Add a new Timeline using PivotTable as data source
         sheet.getTimelines().add(pivot, "i15", "date");

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
destCellNamejava.lang.StringThe cell name in the upper-left corner of the Timeline range.
baseFieldNamejava.lang.StringThe name of PivotField in PivotTable.BaseFields

Returns: int - The new add Timeline index

add(Object o)

public int add(Object o)

Adds an item to the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectThe Object to add to the CollectionBase instance.

Returns: int - The position into which the new element was inserted.

clear()

public void clear()

Removes all objects from the CollectionBase instance.

contains(Object o)

public boolean contains(Object o)

Return whether instance contains this object

Parameters:

ParameterTypeDescription
ojava.lang.Objecttest object

Returns: boolean - Whether instance contains this object

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

get(int index)

public Timeline get(int index)

Gets the Timeline by index.

Example

         //Get the Timeline by index.
         Timeline objByIndex = sheet.getTimelines().get(0);

Parameters:

ParameterTypeDescription
indexint

Returns: Timeline

get(String name)

public Timeline get(String name)

Gets the Timeline by Timeline’s name.

Example

         //Get the Timeline by Timeline's name.
         Timeline objByName = sheet.getTimelines().get("date");

Parameters:

ParameterTypeDescription
namejava.lang.String

Returns: Timeline

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCount()

public int getCount()

Gets the number of elements contained in the CollectionBase instance.

Returns: int - The number of elements contained in the CollectionBase instance.

hashCode()

public native int hashCode()

Returns: int

indexOf(Object o)

public int indexOf(Object o)

Determines the index of a specific item in the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectDetermines the index of a specific item in the CollectionBase instance.

Returns: int - The index of value if found in the list; otherwise, -1.

iterator()

public Iterator iterator()

Returns an enumerator that iterates through the CollectionBase instance.

Returns: java.util.Iterator - An iterator for the CollectionBase instance.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

removeAt(int index)

public void removeAt(int index)

Removes the item at the specified index.

Parameters:

ParameterTypeDescription
indexintThe zero-based index of the item to remove.

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int