ASF Bugzilla – Attachment 25745 Details for
Bug 49581
[PATCH] Support to modify, remove and add a series to an existing chart
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test case
ApachePOITest.java (text/plain), 3.06 KB, created by
Jens Götze
on 2010-07-10 14:04:53 UTC
(
hide
)
Description:
Test case
Filename:
MIME Type:
Creator:
Jens Götze
Created:
2010-07-10 14:04:53 UTC
Size:
3.06 KB
patch
obsolete
>import java.io.FileInputStream ; >import java.io.FileOutputStream ; >import java.io.IOException ; > >import org.apache.poi.hssf.usermodel.HSSFChart ; >import org.apache.poi.hssf.usermodel.HSSFChart.HSSFSeries ; >import org.apache.poi.hssf.usermodel.HSSFSheet ; >import org.apache.poi.hssf.usermodel.HSSFWorkbook ; >import org.apache.poi.ss.util.CellRangeAddressBase ; > >public class ApachePOITest >{ > public static void main ( String[] args ) > { > FileInputStream inputStream = null ; > FileOutputStream outputStream = null ; > try > { > inputStream = new FileInputStream( "excel_001.xls" ) ; > HSSFWorkbook workbook = new HSSFWorkbook( inputStream ) ; > HSSFSheet sheet = workbook.getSheetAt( 0 ) ; > HSSFChart[] charts = HSSFChart.getSheetCharts( sheet ) ; > for ( HSSFChart chart : charts ) > { > HSSFSeries[] seriesArray = chart.getSeries() ; > System.out.println( "seriesArray.length=" + seriesArray.length ) ; > for ( HSSFSeries series : seriesArray ) > { > System.out.println( "serie.getNumValues()=" + series.getNumValues() ) ; > CellRangeAddressBase range ; > > range = series.getValuesCellRange() ; > System.out.println( range.toString() ) ; > range.setLastRow( range.getLastRow() + 1 ) ; > series.setValuesCellRange( range ) ; > > range = series.getCategoryLabelsCellRange() ; > System.out.println( range.toString() ) ; > range.setLastRow( range.getLastRow() + 1 ) ; > series.setCategoryLabelsCellRange( range ) ; > } > > HSSFSeries newSeries = chart.createSeries() ; > newSeries.setValuesCellRange( new CellRangeAddressBase( 1, 4, 3, 3 ) ) ; > String oldSeriesTitle = newSeries.getSeriesTitle() ; > if ( oldSeriesTitle != null ) > { > System.out.println( "old series title: " + oldSeriesTitle ) ; > newSeries.setSeriesTitle( "new series" ) ; > } > } > > outputStream = new FileOutputStream( "excel_001_output.xls" ) ; > workbook.write( outputStream ) ; > } > catch ( Exception e ) > { > e.printStackTrace() ; > } > finally > { > if ( inputStream != null ) > { > try > { > inputStream.close() ; > } > catch ( IOException e ) > { > e.printStackTrace() ; > } > } > > if ( outputStream != null ) > { > try > { > outputStream.close() ; > } > catch ( IOException e ) > { > e.printStackTrace() ; > } > } > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 49581
:
25743
|
25744
|
25745
|
25746
|
25748
|
25751
|
25752
|
25753
|
25754