Migration to Aspose.Cells 7 from Aspose.Cells 2.5.4.202

Hi,


I’m working on migration our appilcation.
This topic is to see all questions related to migration to library Aspose.Cells 7.
As we know API has been changed, so I would like to ask you about, what is new possible way to call, or new name of classes.
I have found some documentation hrere: ( but seems like it not covered here )
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/entry325010.aspx
Please do not close this topic, until I will say I have no more questions about migration.
Thank you.

HorizontalAlignmentType ( how it is called now ? )
VerticalAlignmentType


Hi,

Please see this code.

Java


Cell cell=workbook.getWorksheets().get(0).getCells().get(“A1”);

Style st= cell.getStyle();

st.setHorizontalAlignment(TextAlignmentType.BOTTOM);

st.setVerticalAlignment(TextAlignmentType.BOTTOM);

cell.setStyle(st);


and
VerticalAlignmentType.CENTRED

? now will be:
TextAlignmentType.CENTER or TextAlignmentType.CENTER_ACROSS

Hello,


Also,
what is the new call for:
Chart aChart = addChartToWorksheet( worksheet, chart );
int chartHeightInRows = aChart.getChartShape().getLowerRightRow() - lastRow.getValue();

new way to call : chart.getChartShape() ???


next question, how I can add chart to charts?
previously it looks like:
com.aspose.cells.Chart aChart = charts.addChart( aChartType,
chart.getShape().getRow(),
chart.getShape().getColumn(),
chart.getShape().getLeft(),
chart.getShape().getTop(),
chart.getShape().getWidth(),
chart.getShape().getHeight() );




Hello,

previously it works: nSeries.add(); but now - nope.
how to use it now: nSeries.add();???

SeriesCollection nSeries = aChart.getNSeries();

// draw for each series
for( int i = 0; i < series.length; i++ )
{
int aNum = nSeries.add();
Series aSeries = nSeries.get( aNum );
String columnName = getColumnName( i + 1 );
aSeries.setName( StringUtils.stripHtml( series[i].getName() ) );

// set Series values range
aSeries.setValues( "DataSheet!" + columnName + (nextDataRow + 2) +
":" + columnName + (dataCategories.length + nextDataRow + 1) );

Also:


chart.getCategoryAxis().setReversed( true );

new usage ???

series:

aSeries.getArea().setVisible( false );
aSeries.getDataLabels().setSeriesShown( false );
aSeries.getDataLabels().getFont().setColor( Color.getWhite() );
what is new code for this ?



alg:
and
VerticalAlignmentType.CENTRED
? now will be:
TextAlignmentType.CENTER or TextAlignmentType.CENTER_ACROSS



Hi,

Yes, you are right.
alg:
Hello,

Also,
what is the new call for:
Chart aChart = addChartToWorksheet( worksheet, chart );
int chartHeightInRows = aChart.getChartShape().getLowerRightRow() - lastRow.getValue();

new way to call : chart.getChartShape() ???


next question, how I can add chart to charts?
previously it looks like:
com.aspose.cells.Chart aChart = charts.addChart( aChartType,
chart.getShape().getRow(),
chart.getShape().getColumn(),
chart.getShape().getLeft(),
chart.getShape().getTop(),
chart.getShape().getWidth(),
chart.getShape().getHeight() );






Hi,

Please see this code

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

int chartIndex = worksheet.getCharts().add(ChartType.PYRAMID,5,0,15,5);
Chart chart = worksheet.getCharts().get(chartIndex);


Please see this document for more reference:
How to Create a Chart?
alg:
Hello,

previously it works: nSeries.add(); but now - nope.
how to use it now: nSeries.add();???

SeriesCollection nSeries = aChart.getNSeries();

// draw for each series
for( int i = 0; i < series.length; i++ )
{
int aNum = nSeries.add();
Series aSeries = nSeries.get( aNum );
String columnName = getColumnName( i + 1 );
aSeries.setName( StringUtils.stripHtml( series[i].getName() ) );

// set Series values range
aSeries.setValues( "DataSheet!" + columnName + (nextDataRow + 2) +
":" + columnName + (dataCategories.length + nextDataRow + 1) );



Hi,

Please see this code for series example.

Java
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
//Adding a sample value to "A1" cell
worksheet.getCells().get("A1").putValue(50);
//Adding a sample value to "A2" cell
worksheet.getCells().get("A2").putValue(100);
//Adding a sample value to "A3" cell
worksheet.getCells().get("A3").putValue(150);
//Adding a sample value to "A4" cell
worksheet.getCells().get("A4").putValue(200);
//Adding a sample value to "B1" cell
worksheet.getCells().get("B1").putValue(60);
//Adding a sample value to "B2" cell
worksheet.getCells().get("B2").putValue(32);
//Adding a sample value to "B3" cell
worksheet.getCells().get("B3").putValue(50);
//Adding a sample value to "B4" cell
worksheet.getCells().get("B4").putValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.getCells().get("C1").putValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.getCells().get("C2").putValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.getCells().get("C3").putValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.getCells().get("C4").putValue("Y2");
//Adding a chart to the worksheet
int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.getCharts().get(chartIndex);
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.getNSeries().add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.getNSeries().setCategoryData("C1:C4");
//Saving the Excel file
workbook.save("C:\\book1.xls");

alg:
Also:

chart.getCategoryAxis().setReversed( true );

new usage ???

series:

aSeries.getArea().setVisible( false );
aSeries.getDataLabels().setSeriesShown( false );
aSeries.getDataLabels().getFont().setColor( Color.getWhite() );
what is new code for this ?




Hi,

Please try this.

chart.getCategoryAxis().setPlotOrderReversed(true);
And,

alg:
.........
new way to call : chart.getChartShape() ???
....

Please use Chart.getChartObject() to get ChartShape. Browse the ChartShape class for all your desired methods.


Thank you.

Hi,


Mshakell.faiz, thank you. ( it works, chart.getCategoryAxis().setPlotOrderReversed(true); )

and what about:
Series aSeries
aSeries.getArea().setVisible( false ); ???
aSeries.getDataLabels().setSeriesShown( false ) ???
aSeries.getDataLabels().getFont() ???

Hi,


Thank you, but actualy previously it was much more parameters in order to create chart, now I can see we need to use only 4 int parameters, and chart type.
Before we need to set 6 int parameters + chart type.

new usage example:
//Adding a chart to the worksheet
int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.getCharts().get(chartIndex);


so, how I can add chart to charts?
previously it looks like:
com.aspose.cells.Chart aChart = charts.addChart( aChartType,
chart.getShape().getRow(),
chart.getShape().getColumn(),
chart.getShape().getLeft(),
chart.getShape().getTop(),
chart.getShape().getWidth(),
chart.getShape().getHeight() );

how I need to change it in order to have same behavior?

Also where I can find API documentation for old java cells version: 2.5.4.20 ?

Hi,


I think you may try with latest API set, e.g

aSeries.getArea().setTransparency(1);
aSeries.getDataLabels().setShowSeriesName(false);
aSeries.getDataLabels().getTextFont() …


Thank you.

Hi,


Sorry for a mistake, please change my first line:
aSeries.getArea().setTransparency(1);
to:
aSeries.getArea().setFormatting(FormattingType.NONE);

Thank you.

Hi,


I think you may add the chart using the latest API set and then get the ChartShape using chart.getChartObject() method, now you may specify your desired attributes accordingly.

For the older APIs docs, please download Aspose.Cells for Java v2.5.4 from the download module. And for older Documentation topics for the older API set, you may download the offline documentation of the product, it is still there for older API set. We will update/replace the offline documentation soon, so you may hurry up to download it.
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/category1361.aspx

Thank you.


Hi,

add(java.lang.String area, boolean isVertical)
Again, about series,

previously it works: nSeries.add(); but now - nope.
how to use it now: nSeries.add();???

SeriesCollection nSeries = aChart.getNSeries();

// draw for each series
for( int i = 0; i < series.length; i++ )
{
int aNum = nSeries.add();
Series aSeries = nSeries.get( aNum );
aSeries.setValues( "DataSheet!" + columnName + (nextDataRow + 2) +
":" + columnName + (dataCategories.length + nextDataRow + 1) );

I have understood correctly, that now I need to create series in the following manner:????

nSeries.add("DataSheet!" + columnName + (nextDataRow + 2) +
":" + columnName + (dataCategories.length + nextDataRow + 1) , false );
so we need to put values, yes? and second parameter 'boolean isVertical' should be set to false or true?
Hi,

Thank you! Step by step I go ahead... to cells 7.

These questions are still open:
https://forum.aspose.com/t/122578
https://forum.aspose.com/t/122578

1) we don't have now class: com.aspose.cells.AsposeLicenseException ( Can I remove it ? )
so now, these code : will not throw such exception ?
com.aspose.cells.License license = new com.aspose.cells.License();
license.setLicense( inputStream );

2) How it is possible to call:
chart.getCategoryAxis().getArea() ?? now?

3) Previously I have used: FileFormatType.EXCEL2007, but now seems like: EXCEL_2007_XLSX, but it is deprecated, why ???
what I should use insted of this deprecated constant ?

4) I have used before this constant:
ChartType.COLUMN_CLUSTERED
but now what is it ? this one : COLUMN_3_D_CLUSTERED??

5) I have understood correctly, that it is the same behavior (before and now), yes ???
before:
InputStream workbookInputStream = createSimpleChartWorkbook();
Workbook workbook = new Workbook();
workbook.open( workbookInputStream );

now:
InputStream workbookInputStream = createSimpleChartWorkbook();
Workbook workbook = null;
try
{
workbook = new Workbook( workbookInputStream );
}
catch( Exception e )
{
//exception
}

6) this is correct re-writing?
before:
Worksheet chartSheet = worksheets.addSheet( SheetType.CHART );
chartSheet.setName( "ChartSheet" );
now:
Worksheet chartSheet = worksheets.add ( "ChartSheet" );
chartSheet.setType( SheetType.CHART );

Hi,


1) Please now use and handle CellsException, you may utilize getCode method, i.e.
public int getCode() → that represents custom exception code. The value of the property is ExceptionType integer constant. The ExceptionType has all your desired exception types and many more.

2) If you need to set formatting for tick labels, please use:
e.g
chart.getCategoryAxis.getTickLables()… → it gives you TickLabels object and now you can format using its different methods accordingly.
If you need to format axis line, you may use:
chart.getCategoryAxis.getAxisLine()…–> it gives you Line object, that you may use to format the axis line accordingly.

3) For loading excel files use LoadOptions() class object to specify the load format type i.e. LoadFormat.XLSX → to specify the Excel 2007/2010 XLSX format type.
Similar while saving you need to use specified SaveOptions to set SaveFormat type accordingly.
See the documents in the section for your complete reference.
http://www.aspose.com/documentation/java-components/aspose.cells-for-java/file-handling-features.html

4) Use ChartType.COLUMN for creating clustered column chart.

5) Your understanding is correct.

6) Correct!

And, for:

Migration to Aspose.Cells 7 from Aspose.Cells 2.5.4.202

Please see the reply:
https://forum.aspose.com/t/122578

Thank you.