Migration to Aspose.Cells 7 (2)

Hi,

com.aspose.cells.Style aStyle = aCell.getStyle();

how I can set these properties now?
BorderLine, BorderColor, Color,

aStyle.setBorderLine( BorderType.TOP_BORDER, convertToAsposeBorderLineType( borderLineTop ) );
aStyle.setBorderColor( BorderType.BOTTOM_BORDER, convertToAsposeColor( borderColorBottom ) );
aStyle.setColor( Color.fromArgb( color.getRed(),
color.getGreen(),
color.getBlue() ) );




DataLabels datalabels = nSeries.get( i ).getDataLabels();
what I can use now: ???
datalabels.setLabelPosition( style.getLabelPosition() );


what I can use now:
SortOrderType.DESCENDING
??

what I can use now:??
worksheets.moveSheet( worksheets.get( STATISTICS_SHEET_NAME ).getIndex(), 1 );

how I can load data now:??
Workbook workbook = new Workbook();
workbook.loadData( dataFile.getAbsolutePath() );
somehow I need to use LoadOptions, but how?
previously I can make:
Font defaultFont = new Font( );
defaultFont.setName( "Segou UI" );
defaultFont.setSize( 9 );
chart.getCategoryAxis().setFont( defaultFont );
chart.getChartDataTable().setFont( defaultFont );
chart.getChartArea().setFont( defaultFont );
chart.getLegend().setFont( defaultFont );

but now I need to write:
Font textFont = chart.getCategoryAxis().getTitle().getTextFont();
textFont.setName( "Segou UI" );
textFont.setSize( 9 );
Font font = chart.getChartDataTable().getFont();
font.setName( "Segou UI" );
font.setSize( 9 );
Font textFont1 = chart.getChartArea().getTextFont();
textFont1.setName( "Segou UI" );
textFont1.setSize( 9 );
Font textFont2 = chart.getLegend().getTextFont();
textFont2.setName( "Segou UI" );
textFont2.setSize( 9 );

Сan write it like: ( font = textFont; ??? ) (seems like 1 line per object will be less )
Font textFont = chart.getCategoryAxis().getTitle().getTextFont();
textFont.setName( "Segou UI" );
textFont.setSize( 9 );
Font font = chart.getChartDataTable().getFont();
font = textFont;
Font textFont1 = chart.getChartArea().getTextFont();
textFont1 = textFont;
Font textFont2 = chart.getLegend().getTextFont();
textFont2 = textFont;

Hi,

I think, it is a good approach and saves your lines, one font object for all of the chart objects, but you need to test it though.

Hi,

1)
worksheet.getShapes().addTextBox(10,11,12,13,14,15);

Now should be:

worksheet.getShapes().addShape(MsoDrawingType.TEXT_BOX,10, 12, 11, 13, 15, 14);

Please pay more attention to the change of parameters order from old to new versions.

2)
textBox.setFilled( false );
textBox.getLine().setVisible( false );
textBox.setContent( title );

Now should be:

textBox.getFillFormat().setVisible(false);
textBox.getLineFormat().setVisible(false)
textBox.setText(title);


3)
pageSetup.setLeftHeader( header );
pageSetup.setDifferentFirstPage( true );
pageSetup.setsetCenterFooter( footer );

Now should be:

pageSetup.setHeader(0, header);
pageSetup.setHFDiffFirst(true);
pageSetup.setFooter(1, footer);

4)
aStyle.setBorderLine( BorderType.TOP_BORDER, convertToAsposeBorderLineType( borderLineTop ) );
aStyle.setBorderColor( BorderType.BOTTOM_BORDER, convertToAsposeColor( borderColorBottom ) );
aStyle.setColor( Color.fromArgb( color.getRed(),color.getGreen(),color.getBlue() ) );

Now please use following APIs:

style.getBorders().getByBorderType(BorderType.TOP_BORDER)
Border.setLineStyle()/setColor()

Or

Style.setBorder(borderType, borderStyle, borderColor)

5)

datalabels.setLabelPosition()

Now should be:

DataLabels.setPosition()

6)
SortOrderType.DESCENDING

Now changed to

SortOrder.DESCENDING

7)
worksheets.moveSheet( worksheets.get( STATISTICS_SHEET_NAME ).getIndex(), 1 );

Now should be:

worksheets.get(STATISTICS_SHEET_NAME).move(1);

8)
Workbook.loadData(...)

Please use

LoadOptions by setLoadDataOnly(true)


9)
For the code of apply same font to multiple components, I don’t think your code will take effect. In Java language, assigning a new value to a local variable will not effect other objects that used the variable previously. To simplify your code a bit, we think you can create a method to custom the font, code like following:

setChartFont(chart.getCategoryAxis().getTitle().getTextFont());
setChartFont(chart.getChartDataTable().getFont());
setChartFont(chart.getChartArea().getTextFont());
setChartFont(chart.getLegend().getTextFont());
private void setChartFont(Font font)
{
font.setName("Segou UI");
font.setSize(9);
}

Hi,

Thank you for your answer. It works.

1) So If I need to get this object, I should cast it ? yes?
Shape shape = worksheet.getShapes().addShape( MsoDrawingType.TEXT_BOX, 10, 10, 10, 10, 10, 10 );
TextBox textBox = (TextBox) shape; ???


2) private static void setDataLabels( Series aSeries )
{
DataLabels dataLabels = aSeries.getDataLabels();
How it is possible to get dataLabels from series ?

3) this is correct ???
that I need to change
VPageBreak class to new one ->> VerticalPageBreak

4) com.aspose.cells.Style aStyle = aCell.getStyle();
Style.setColor ->> How I can set it now???

5) How I can get Area now??
Chart aChart;
aChart.getValueAxis().getArea().setAuto( false );

6) previously I have used:
workbook.open( fileName, FileFormatType.EXCEL_2007_XLSX );
how I can make it now?
especcialy I'm interested in: FileFormatType.EXCEL_2007_XLSX ???
also how I can make it now:
workbook.setFileFormatType( FileFormatType.EXCEL_97_TO_2003 ); ???

7) how I can set secondCategoryData now ???
SeriesCollection nSeries = asposeChart.getNSeries();
nSeries.setSecondCategoryData( "A2:A4" );

Hi,


My last question is still actualy:
Migration to Aspose.Cells 7 (2)
Thank you.

Hi,

1) Yes, please cast it.

2) Please use chart.getNSeries().get(0).getDataLabels();

3) Yes, it is now VerticalPageBreak

4) Use
Style st=cell.getStyle();
st.getFont().setColor(arg0);

5) It’s strange, I don’t chart.getValueAxis().getArea(), we will implement it.

6) You will now just use constructor i.e
String filePath = “c:\yourfile.xlsx”;
Workbook workbook = new Workbook(filePath);

You don’t need to specify its extension.

7) I find, you can set it using ch.getNSeries().setSecondCatergoryData() method.

Hi,

Please see the following more correct ways.

4) Style.setColor()

Now please use:

style.setPattern(BackgroundType.SOLID);
style.setForegroundColor(color);
6)
If you want to specify the file format when opening a template file, please use LoadOptions, code like following:

LoadOptions opt = new LoadOptions(FileFormatType.XLSX)
workbook = new Workbook(path, opt);
...
And

workbook.setFileFormatType( FileFormatType.EXCEL_97_TO_2003 );

now is:

workbook.setFileFormat(FileFormatType.EXCEL_97_TO_2003);

Hello,


Thank you.
This was the last my question for a successful migration.

So, in order to make it ( get Area ans setAuto )
aChart.getValueAxis().getArea().setAuto( false );
It will be possible to make in next aspose.cells version ?
when approximately I can download it ?

Hi,

For your requirement about Axis.getArea():

We are afraid even in old versions setting the area of Axis is not supported yet. In old versions Axis.getArea() is only an empty API without implementation. Setting properties for the returned Area object does not take effect for the Chart.

For the new version, we will add such a method in later versions when we can support to set and save user’s settings for the area object of chart Axis. But we are afraid we need more time to support this feature after some other important tasks.