Search in sources :

Example 1 with LegendRecord

use of org.apache.poi.hssf.record.chart.LegendRecord in project poi by apache.

the class HSSFChart method createLegendRecord.

private LegendRecord createLegendRecord() {
    LegendRecord r = new LegendRecord();
    r.setXAxisUpperLeft(3542);
    r.setYAxisUpperLeft(1566);
    r.setXSize(437);
    r.setYSize(213);
    r.setType(LegendRecord.TYPE_RIGHT);
    r.setSpacing(LegendRecord.SPACING_MEDIUM);
    r.setAutoPosition(true);
    r.setAutoSeries(true);
    r.setAutoXPositioning(true);
    r.setAutoYPositioning(true);
    r.setVertical(true);
    r.setDataTable(false);
    return r;
}
Also used : LegendRecord(org.apache.poi.hssf.record.chart.LegendRecord)

Example 2 with LegendRecord

use of org.apache.poi.hssf.record.chart.LegendRecord in project poi by apache.

the class HSSFChart method getSheetCharts.

/**
	 * Returns all the charts for the given sheet.
	 *
	 * NOTE: You won't be able to do very much with
	 *  these charts yet, as this is very limited support
	 */
public static HSSFChart[] getSheetCharts(HSSFSheet sheet) {
    List<HSSFChart> charts = new ArrayList<HSSFChart>();
    HSSFChart lastChart = null;
    HSSFSeries lastSeries = null;
    // Find records of interest
    List<RecordBase> records = sheet.getSheet().getRecords();
    for (RecordBase r : records) {
        if (r instanceof ChartRecord) {
            lastSeries = null;
            lastChart = new HSSFChart(sheet, (ChartRecord) r);
            charts.add(lastChart);
        } else if (r instanceof LinkedDataRecord) {
            LinkedDataRecord linkedDataRecord = (LinkedDataRecord) r;
            if (lastSeries != null) {
                lastSeries.insertData(linkedDataRecord);
            }
        }
        if (lastChart == null) {
            continue;
        }
        if (r instanceof LegendRecord) {
            lastChart.legendRecord = (LegendRecord) r;
        } else if (r instanceof SeriesRecord) {
            HSSFSeries series = new HSSFSeries((SeriesRecord) r);
            lastChart.series.add(series);
            lastSeries = series;
        } else if (r instanceof ChartTitleFormatRecord) {
            lastChart.chartTitleFormat = (ChartTitleFormatRecord) r;
        } else if (r instanceof SeriesTextRecord) {
            // Applies to a series, unless we've seen a legend already
            SeriesTextRecord str = (SeriesTextRecord) r;
            if (lastChart.legendRecord == null && lastChart.series.size() > 0) {
                HSSFSeries series = lastChart.series.get(lastChart.series.size() - 1);
                series.seriesTitleText = str;
            } else {
                lastChart.chartTitleText = str;
            }
        } else if (r instanceof ValueRangeRecord) {
            lastChart.valueRanges.add((ValueRangeRecord) r);
        } else if (r instanceof Record) {
            Record record = (Record) r;
            for (HSSFChartType type : HSSFChartType.values()) {
                if (type == HSSFChartType.Unknown) {
                    continue;
                }
                if (record.getSid() == type.getSid()) {
                    lastChart.type = type;
                    break;
                }
            }
        }
    }
    return charts.toArray(new HSSFChart[charts.size()]);
}
Also used : LegendRecord(org.apache.poi.hssf.record.chart.LegendRecord) SeriesTextRecord(org.apache.poi.hssf.record.chart.SeriesTextRecord) ArrayList(java.util.ArrayList) ChartRecord(org.apache.poi.hssf.record.chart.ChartRecord) SeriesRecord(org.apache.poi.hssf.record.chart.SeriesRecord) ChartTitleFormatRecord(org.apache.poi.hssf.record.chart.ChartTitleFormatRecord) RecordBase(org.apache.poi.hssf.record.RecordBase) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) VCenterRecord(org.apache.poi.hssf.record.VCenterRecord) AxisUsedRecord(org.apache.poi.hssf.record.chart.AxisUsedRecord) LinkedDataRecord(org.apache.poi.hssf.record.chart.LinkedDataRecord) FooterRecord(org.apache.poi.hssf.record.FooterRecord) SCLRecord(org.apache.poi.hssf.record.SCLRecord) ChartRecord(org.apache.poi.hssf.record.chart.ChartRecord) ValueRangeRecord(org.apache.poi.hssf.record.chart.ValueRangeRecord) LegendRecord(org.apache.poi.hssf.record.chart.LegendRecord) SeriesTextRecord(org.apache.poi.hssf.record.chart.SeriesTextRecord) AxisParentRecord(org.apache.poi.hssf.record.chart.AxisParentRecord) DefaultDataLabelTextPropertiesRecord(org.apache.poi.hssf.record.chart.DefaultDataLabelTextPropertiesRecord) PrintSetupRecord(org.apache.poi.hssf.record.PrintSetupRecord) Record(org.apache.poi.hssf.record.Record) SeriesToChartGroupRecord(org.apache.poi.hssf.record.chart.SeriesToChartGroupRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) AreaFormatRecord(org.apache.poi.hssf.record.chart.AreaFormatRecord) BeginRecord(org.apache.poi.hssf.record.chart.BeginRecord) HCenterRecord(org.apache.poi.hssf.record.HCenterRecord) EndRecord(org.apache.poi.hssf.record.chart.EndRecord) PlotGrowthRecord(org.apache.poi.hssf.record.chart.PlotGrowthRecord) UnitsRecord(org.apache.poi.hssf.record.chart.UnitsRecord) HeaderRecord(org.apache.poi.hssf.record.HeaderRecord) SeriesRecord(org.apache.poi.hssf.record.chart.SeriesRecord) BarRecord(org.apache.poi.hssf.record.chart.BarRecord) ChartFormatRecord(org.apache.poi.hssf.record.chart.ChartFormatRecord) AxisLineFormatRecord(org.apache.poi.hssf.record.chart.AxisLineFormatRecord) CategorySeriesAxisRecord(org.apache.poi.hssf.record.chart.CategorySeriesAxisRecord) ChartTitleFormatRecord(org.apache.poi.hssf.record.chart.ChartTitleFormatRecord) FrameRecord(org.apache.poi.hssf.record.chart.FrameRecord) PlotAreaRecord(org.apache.poi.hssf.record.chart.PlotAreaRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) DataFormatRecord(org.apache.poi.hssf.record.chart.DataFormatRecord) ProtectRecord(org.apache.poi.hssf.record.ProtectRecord) TextRecord(org.apache.poi.hssf.record.chart.TextRecord) FontBasisRecord(org.apache.poi.hssf.record.chart.FontBasisRecord) AxisOptionsRecord(org.apache.poi.hssf.record.chart.AxisOptionsRecord) SeriesIndexRecord(org.apache.poi.hssf.record.chart.SeriesIndexRecord) SheetPropertiesRecord(org.apache.poi.hssf.record.chart.SheetPropertiesRecord) TickRecord(org.apache.poi.hssf.record.chart.TickRecord) AxisRecord(org.apache.poi.hssf.record.chart.AxisRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) FontIndexRecord(org.apache.poi.hssf.record.chart.FontIndexRecord) LineFormatRecord(org.apache.poi.hssf.record.chart.LineFormatRecord) LinkedDataRecord(org.apache.poi.hssf.record.chart.LinkedDataRecord) ValueRangeRecord(org.apache.poi.hssf.record.chart.ValueRangeRecord)

Aggregations

LegendRecord (org.apache.poi.hssf.record.chart.LegendRecord)2 ArrayList (java.util.ArrayList)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)1 EOFRecord (org.apache.poi.hssf.record.EOFRecord)1 FooterRecord (org.apache.poi.hssf.record.FooterRecord)1 HCenterRecord (org.apache.poi.hssf.record.HCenterRecord)1 HeaderRecord (org.apache.poi.hssf.record.HeaderRecord)1 PrintSetupRecord (org.apache.poi.hssf.record.PrintSetupRecord)1 ProtectRecord (org.apache.poi.hssf.record.ProtectRecord)1 Record (org.apache.poi.hssf.record.Record)1 RecordBase (org.apache.poi.hssf.record.RecordBase)1 SCLRecord (org.apache.poi.hssf.record.SCLRecord)1 UnknownRecord (org.apache.poi.hssf.record.UnknownRecord)1 VCenterRecord (org.apache.poi.hssf.record.VCenterRecord)1 AreaFormatRecord (org.apache.poi.hssf.record.chart.AreaFormatRecord)1 AxisLineFormatRecord (org.apache.poi.hssf.record.chart.AxisLineFormatRecord)1 AxisOptionsRecord (org.apache.poi.hssf.record.chart.AxisOptionsRecord)1 AxisParentRecord (org.apache.poi.hssf.record.chart.AxisParentRecord)1 AxisRecord (org.apache.poi.hssf.record.chart.AxisRecord)1