org.apache.poi.hssf.record.MergeCellsRecord Java Examples
The following examples show how to use
org.apache.poi.hssf.record.MergeCellsRecord.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RowBlock.java From dremio-oss with Apache License 2.0 | 7 votes |
public void process(Record r) { switch (r.getSid()) { case MergeCellsRecord.sid: mergeCellRecords.add((MergeCellsRecord) r); break; case SharedFormulaRecord.sid: shFrmRecords.add((SharedFormulaRecord) r); if (!(prevRec instanceof FormulaRecord)) { throw new RuntimeException("Shared formula record should follow a FormulaRecord"); } FormulaRecord fr = (FormulaRecord) prevRec; firstCellRefs.add(new CellReference(fr.getRow(), fr.getColumn())); break; case ArrayRecord.sid: arrayRecords.add((ArrayRecord) r); break; case TableRecord.sid: tableRecords.add((TableRecord) r); break; default: plainRecords.add(r); break; } prevRec = r; }
Example #2
Source File: MergeCellsRecordHandler.java From easyexcel with Apache License 2.0 | 5 votes |
@Override public void processRecord(XlsReadContext xlsReadContext, Record record) { MergeCellsRecord mcr = (MergeCellsRecord)record; for (int i = 0; i < mcr.getNumAreas(); i++) { CellRangeAddress cellRangeAddress = mcr.getAreaAt(i); CellExtra cellExtra = new CellExtra(CellExtraTypeEnum.MERGE, null, cellRangeAddress.getFirstRow(), cellRangeAddress.getLastRow(), cellRangeAddress.getFirstColumn(), cellRangeAddress.getLastColumn()); xlsReadContext.xlsReadSheetHolder().setCellExtra(cellExtra); xlsReadContext.analysisEventProcessor().extra(xlsReadContext); } }
Example #3
Source File: MergedCellsTable.java From lams with GNU General Public License v2.0 | 5 votes |
/** * reads zero or more consecutive {@link MergeCellsRecord}s * @param rs */ public void read(RecordStream rs) { List<CellRangeAddress> temp = _mergedRegions; while (rs.peekNextClass() == MergeCellsRecord.class) { MergeCellsRecord mcr = (MergeCellsRecord) rs.getNext(); int nRegions = mcr.getNumAreas(); for (int i = 0; i < nRegions; i++) { CellRangeAddress cra = mcr.getAreaAt(i); temp.add(cra); } } }
Example #4
Source File: MergedCellsTable.java From lams with GNU General Public License v2.0 | 5 votes |
private void addMergeCellsRecord(MergeCellsRecord mcr) { int nRegions = mcr.getNumAreas(); for (int i = 0; i < nRegions; i++) { CellRangeAddress cra = mcr.getAreaAt(i); _mergedRegions.add(cra); } }
Example #5
Source File: XlsRecordProcessor.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * Stores all {@link CellRangeAddress} areas found in the record in mergeCells map * * @param mcr MergeCellsRecord */ private void processMergeCellRecord(final MergeCellsRecord mcr) { int nRegions = mcr.getNumAreas(); for (int i = 0; i < nRegions; i++) { final CellRangeAddress area = mcr.getAreaAt(i); int cellId = computeCellId(area.getFirstRow(), area.getFirstColumn()); MergedCell prev = mergeCells.put(cellId, new MergedCell(area)); assert prev == null : "two merge cells share the same top/left cell"; } }
Example #6
Source File: RowBlocksReader.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Also collects any loose MergeCellRecords and puts them in the supplied * mergedCellsTable * * @param rs the record stream */ public RowBlocksReader(RecordStream rs) { List<Record> plainRecords = new ArrayList<Record>(); List<Record> shFrmRecords = new ArrayList<Record>(); List<CellReference> firstCellRefs = new ArrayList<CellReference>(); List<Record> arrayRecords = new ArrayList<Record>(); List<Record> tableRecords = new ArrayList<Record>(); List<Record> mergeCellRecords = new ArrayList<Record>(); Record prevRec = null; while(!RecordOrderer.isEndOfRowBlock(rs.peekNextSid())) { // End of row/cell records for the current sheet // Note - It is important that this code does not inadvertently add any sheet // records from a subsequent sheet. For example, if SharedFormulaRecords // are taken from the wrong sheet, this could cause bug 44449. if (!rs.hasNext()) { throw new RuntimeException("Failed to find end of row/cell records"); } Record rec = rs.getNext(); List<Record> dest; switch (rec.getSid()) { case MergeCellsRecord.sid: dest = mergeCellRecords; break; case SharedFormulaRecord.sid: dest = shFrmRecords; if (!(prevRec instanceof FormulaRecord)) { throw new RuntimeException("Shared formula record should follow a FormulaRecord"); } FormulaRecord fr = (FormulaRecord)prevRec; firstCellRefs.add(new CellReference(fr.getRow(), fr.getColumn())); break; case ArrayRecord.sid: dest = arrayRecords; break; case TableRecord.sid: dest = tableRecords; break; default: dest = plainRecords; } dest.add(rec); prevRec = rec; } SharedFormulaRecord[] sharedFormulaRecs = new SharedFormulaRecord[shFrmRecords.size()]; CellReference[] firstCells = new CellReference[firstCellRefs.size()]; ArrayRecord[] arrayRecs = new ArrayRecord[arrayRecords.size()]; TableRecord[] tableRecs = new TableRecord[tableRecords.size()]; shFrmRecords.toArray(sharedFormulaRecs); firstCellRefs.toArray(firstCells); arrayRecords.toArray(arrayRecs); tableRecords.toArray(tableRecs); _plainRecords = plainRecords; _sfm = SharedValueManager.create(sharedFormulaRecs, firstCells, arrayRecs, tableRecs); _mergedCellsRecords = new MergeCellsRecord[mergeCellRecords.size()]; mergeCellRecords.toArray(_mergedCellsRecords); }
Example #7
Source File: MergedCellsTable.java From lams with GNU General Public License v2.0 | 4 votes |
public void addRecords(MergeCellsRecord[] mcrs) { for (int i = 0; i < mcrs.length; i++) { addMergeCellsRecord(mcrs[i]); } }
Example #8
Source File: RowBlock.java From dremio-oss with Apache License 2.0 | 4 votes |
List<MergeCellsRecord> getMergeCellRecords() { return mergeCellRecords; }
Example #9
Source File: RowBlocksReader.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Some unconventional apps place {@link MergeCellsRecord}s within the row block. They * actually should be in the {@link MergedCellsTable} which is much later (see bug 45699). * @return any loose <tt>MergeCellsRecord</tt>s found */ public MergeCellsRecord[] getLooseMergedCells() { return _mergedCellsRecords; }