org.apache.poi.hssf.record.BoundSheetRecord Java Examples

The following examples show how to use org.apache.poi.hssf.record.BoundSheetRecord. 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: BofRecordHandler.java    From easyexcel with Apache License 2.0 6 votes vote down vote up
private void initReadSheetDataList(XlsReadWorkbookHolder xlsReadWorkbookHolder) {
    if (xlsReadWorkbookHolder.getActualSheetDataList() != null) {
        return;
    }
    BoundSheetRecord[] boundSheetRecords =
        BoundSheetRecord.orderByBofPosition(xlsReadWorkbookHolder.getBoundSheetRecordList());
    List<ReadSheet> readSheetDataList = new ArrayList<ReadSheet>();
    for (int i = 0; i < boundSheetRecords.length; i++) {
        BoundSheetRecord boundSheetRecord = boundSheetRecords[i];
        ReadSheet readSheet = new ReadSheet(i, boundSheetRecord.getSheetname());
        readSheetDataList.add(readSheet);
    }
    xlsReadWorkbookHolder.setActualSheetDataList(readSheetDataList);
    // Just need to get the list of sheets
    if (!xlsReadWorkbookHolder.getNeedReadSheet()) {
        throw new ExcelAnalysisStopException("Just need to get the list of sheets.");
    }
}
 
Example #2
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines whether a workbook contains the provided sheet name.  For the purpose of
 * comparison, long names are truncated to 31 chars.
 *
 * @param name the name to test (case insensitive match)
 * @param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the check.
 * @return true if the sheet contains the name, false otherwise.
 */
public boolean doesContainsSheetName(String name, int excludeSheetIdx) {
    String aName = name;
    if (aName.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {
        aName = aName.substring(0, MAX_SENSITIVE_SHEET_NAME_LEN);
    }
    int i=0;
    for (BoundSheetRecord boundSheetRecord : boundsheets) {
        if (excludeSheetIdx == i++) {
            continue;
        }
        String bName = boundSheetRecord.getSheetname();
        if (bName.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {
            bName = bName.substring(0, MAX_SENSITIVE_SHEET_NAME_LEN);
        }
        if (aName.equalsIgnoreCase(bName)) {
            return true;
        }
    }
    return false;
}
 
Example #3
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * if we're trying to address one more sheet than we have, go ahead and add it!  if we're
 * trying to address >1 more than we have throw an exception!
 */
private void checkSheets(int sheetnum) {
    if ((boundsheets.size()) <= sheetnum) {   // if we're short one add another..
        if ((boundsheets.size() + 1) <= sheetnum) {
            throw new RuntimeException("Sheet number out of bounds!");
        }
        BoundSheetRecord bsr = createBoundSheet(sheetnum);

        records.add(records.getBspos()+1, bsr);
        records.setBspos( records.getBspos() + 1 );
        boundsheets.add(bsr);
        getOrCreateLinkTable().checkExternSheet(sheetnum);
        fixTabIdRecord();
    }
}
 
Example #4
Source File: XlsReadWorkbookHolder.java    From easyexcel with Apache License 2.0 5 votes vote down vote up
public XlsReadWorkbookHolder(ReadWorkbook readWorkbook) {
    super(readWorkbook);
    this.boundSheetRecordList = new ArrayList<BoundSheetRecord>();
    this.needReadSheet = Boolean.TRUE;
    setExcelType(ExcelTypeEnum.XLS);
    if (getGlobalConfiguration().getUse1904windowing() == null) {
        getGlobalConfiguration().setUse1904windowing(Boolean.FALSE);
    }
    ignoreRecord = Boolean.FALSE;
}
 
Example #5
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the hidden flag for a given sheet.
 * Note that a sheet could instead be
 *  set to be very hidden, which is different
 *  ({@link #isSheetVeryHidden(int)})
 *
 * @param sheetnum the sheet number (0 based)
 * @return True if sheet is hidden
 * @since 3.16 beta 2
 */
public SheetVisibility getSheetVisibility(int sheetnum) {
    final BoundSheetRecord bsr = getBoundSheetRec(sheetnum);
    if (bsr.isVeryHidden()) {
        return SheetVisibility.VERY_HIDDEN;
    }
    if (bsr.isHidden()) {
        return SheetVisibility.HIDDEN;
    }
    return SheetVisibility.VISIBLE;
}
 
Example #6
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * sets the name for a given sheet.  If the boundsheet record doesn't exist and
 * its only one more than we have, go ahead and create it.  If it's &gt; 1 more than
 * we have, except
 *
 * @param sheetnum the sheet number (0 based)
 * @param sheetname the name for the sheet
 */
public void setSheetName(int sheetnum, final String sheetname) {
    checkSheets(sheetnum);

    // YK: Mimic Excel and silently truncate sheet names longer than 31 characters
    String sn = (sheetname.length() > 31) ? sheetname.substring(0, 31) : sheetname;

    BoundSheetRecord sheet = boundsheets.get(sheetnum);
    sheet.setSheetname(sn);
}
 
Example #7
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private InternalWorkbook() {
  	records     = new WorkbookRecordList();

boundsheets = new ArrayList<BoundSheetRecord>();
formats = new ArrayList<FormatRecord>();
hyperlinks = new ArrayList<HyperlinkRecord>();
numxfs = 0;
numfonts = 0;
maxformatid = -1;
uses1904datewindowing = false;
escherBSERecords = new ArrayList<EscherBSERecord>();
commentRecords = new LinkedHashMap<String, NameCommentRecord>();
  }
 
Example #8
Source File: EventWorkbookBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Process the record ourselves, but do not
 *  pass it on to the child Listener.
 *  
 * @param record the record to be processed
 */
public void processRecordInternally(Record record) {
	if(record instanceof BoundSheetRecord) {
		boundSheetRecords.add((BoundSheetRecord)record);
	}
	else if(record instanceof ExternSheetRecord) {
		externSheetRecords.add((ExternSheetRecord)record);
	}
	else if(record instanceof SSTRecord) {
		sstRecord = (SSTRecord)record;
	}
}
 
Example #9
Source File: EventWorkbookBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public HSSFWorkbook getStubHSSFWorkbook() {
    // Create a base workbook
    HSSFWorkbook wb = HSSFWorkbook.create(getStubWorkbook());
    // Stub the sheets, so sheet name lookups work
    for (BoundSheetRecord bsr : boundSheetRecords) {
        wb.createSheet(bsr.getSheetname());
    }
    // Ready for Formula use!
    return wb;
}
 
Example #10
Source File: EventWorkbookBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a stub Workbook from the supplied records,
 *  suitable for use with the {@link HSSFFormulaParser}
 * @param externs The ExternSheetRecords in your file
 * @param bounds The BoundSheetRecords in your file
 * @param sst The SSTRecord in your file.
 * @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
 */
public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs,
		BoundSheetRecord[] bounds, SSTRecord sst) {
	List<Record> wbRecords = new ArrayList<Record>();

	// Core Workbook records go first
	if(bounds != null) {
		for (BoundSheetRecord bound : bounds) {
			wbRecords.add(bound);
		}
	}
	if(sst != null) {
		wbRecords.add(sst);
	}

	// Now we can have the ExternSheetRecords,
	//  preceded by a SupBookRecord
	if(externs != null) {
		wbRecords.add(SupBookRecord.createInternalReferences(
				(short)externs.length));
		for (ExternSheetRecord extern : externs) {
			wbRecords.add(extern);
		}
	}

	// Finally we need an EoF record
	wbRecords.add(EOFRecord.instance);

	return InternalWorkbook.createWorkbook(wbRecords);
}
 
Example #11
Source File: EventBasedExcelExtractor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void processRecord(Record record) {
    String thisText = null;
    int thisRow = -1;

    switch(record.getSid()) {
    case BoundSheetRecord.sid:
        BoundSheetRecord sr = (BoundSheetRecord)record;
        sheetNames.add(sr.getSheetname());
        break;
    case BOFRecord.sid:
        BOFRecord bof = (BOFRecord)record;
        if(bof.getType() == BOFRecord.TYPE_WORKSHEET) {
            sheetNum++;
            rowNum = -1;

            if(_includeSheetNames) {
                if(_text.length() > 0) _text.append("\n");
                _text.append(sheetNames.get(sheetNum));
            }
        }
        break;
    case SSTRecord.sid:
        sstRecord = (SSTRecord)record;
        break;

    case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;
        thisRow = frec.getRow();

        if(_formulasNotResults) {
            thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
        } else {
            if(frec.hasCachedResultString()) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringValue = true;
                nextRow = frec.getRow();
            } else {
                thisText = _ft.formatNumberDateCell(frec);
            }
        }
        break;
    case StringRecord.sid:
        if(outputNextStringValue) {
            // String for formula
            StringRecord srec = (StringRecord)record;
            thisText = srec.getString();
            thisRow = nextRow;
            outputNextStringValue = false;
        }
        break;
    case LabelRecord.sid:
        LabelRecord lrec = (LabelRecord) record;
        thisRow = lrec.getRow();
        thisText = lrec.getValue();
        break;
    case LabelSSTRecord.sid:
        LabelSSTRecord lsrec = (LabelSSTRecord) record;
        thisRow = lsrec.getRow();
        if(sstRecord == null) {
            throw new IllegalStateException("No SST record found");
        }
        thisText = sstRecord.getString(lsrec.getSSTIndex()).toString();
        break;
    case NoteRecord.sid:
        NoteRecord nrec = (NoteRecord) record;
        thisRow = nrec.getRow();
        // TODO: Find object to match nrec.getShapeId()
        break;
    case NumberRecord.sid:
        NumberRecord numrec = (NumberRecord) record;
        thisRow = numrec.getRow();
        thisText = _ft.formatNumberDateCell(numrec);
        break;
    default:
        break;
    }

    if(thisText != null) {
        if(thisRow != rowNum) {
            rowNum = thisRow;
            if(_text.length() > 0)
                _text.append("\n");
        } else {
            _text.append("\t");
        }
        _text.append(thisText);
    }
}
 
Example #12
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private BoundSheetRecord getBoundSheetRec(int sheetIndex) {
    return boundsheets.get(sheetIndex);
}
 
Example #13
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates an empty workbook object with three blank sheets and all the empty
 * fields.  Use this to create a workbook from scratch.
 *
 * @return an empty workbook object
 */
public static InternalWorkbook createWorkbook() {
    LOG.log( DEBUG, "creating new workbook from scratch" );

    InternalWorkbook retval = new InternalWorkbook();
    List<Record> records = new ArrayList<Record>( 30 );
    retval.records.setRecords(records);
    List<FormatRecord> formats = retval.formats;

    records.add(createBOF());
    records.add(new InterfaceHdrRecord(CODEPAGE));
    records.add(createMMS());
    records.add(InterfaceEndRecord.instance);
    records.add(createWriteAccess());
    records.add(createCodepage());
    records.add(createDSF());
    records.add(createTabId());
    retval.records.setTabpos(records.size() - 1);
    records.add(createFnGroupCount());
    records.add(createWindowProtect());
    records.add(createProtect());
    retval.records.setProtpos(records.size() - 1);
    records.add(createPassword());
    records.add(createProtectionRev4());
    records.add(createPasswordRev4());
    retval.windowOne = createWindowOne();
    records.add(retval.windowOne);
    records.add(createBackup());
    retval.records.setBackuppos(records.size() - 1);
    records.add(createHideObj());
    records.add(createDateWindow1904());
    records.add(createPrecision());
    records.add(createRefreshAll());
    records.add(createBookBool());
    records.add(createFont());
    records.add(createFont());
    records.add(createFont());
    records.add(createFont());
    retval.records.setFontpos( records.size() - 1 );   // last font record position
    retval.numfonts = 4;

    // set up format records
    for (int i = 0; i <= 7; i++) {
        FormatRecord rec = createFormat(i);
        retval.maxformatid = retval.maxformatid >= rec.getIndexCode() ? retval.maxformatid : rec.getIndexCode();
        formats.add(rec);
        records.add(rec);
    }

    for (int k = 0; k < 21; k++) {
        records.add(InternalWorkbook.createExtendedFormat(k));
        retval.numxfs++;
    }
    retval.records.setXfpos( records.size() - 1 );
    for (int k = 0; k < 6; k++) {
        records.add(InternalWorkbook.createStyle(k));
    }
    records.add(InternalWorkbook.createUseSelFS());

    int nBoundSheets = 1; // now just do 1
    for (int k = 0; k < nBoundSheets; k++) {
        BoundSheetRecord bsr = createBoundSheet(k);

        records.add(bsr);
        retval.boundsheets.add(bsr);
        retval.records.setBspos(records.size() - 1);
    }
    records.add( InternalWorkbook.createCountry() );
    for ( int k = 0; k < nBoundSheets; k++ ) {
        retval.getOrCreateLinkTable().checkExternSheet(k);
    }
    retval.sst = new SSTRecord();
    records.add(retval.sst);
    records.add(InternalWorkbook.createExtendedSST());

    records.add(EOFRecord.instance);
    LOG.log( DEBUG, "exit create new workbook from scratch" );

    return retval;
}
 
Example #14
Source File: EventWorkbookBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public BoundSheetRecord[] getBoundSheetRecords() {
	return boundSheetRecords.toArray(
			new BoundSheetRecord[boundSheetRecords.size()]
	);
}
 
Example #15
Source File: BoundSheetRecordHandler.java    From easyexcel with Apache License 2.0 4 votes vote down vote up
@Override
public boolean couldDecode(Record record) {
	return BoundSheetRecord.sid == record.getSid();
}
 
Example #16
Source File: HSSFWorkbook.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("resource")
protected void encryptBytes(byte buf[]) {
    EncryptionInfo ei = getEncryptionInfo();
    if (ei == null) {
        return;
    }
    Encryptor enc = ei.getEncryptor();
    int initialOffset = 0;
    LittleEndianByteArrayInputStream plain = new LittleEndianByteArrayInputStream(buf, 0); // NOSONAR
    LittleEndianByteArrayOutputStream leos = new LittleEndianByteArrayOutputStream(buf, 0); // NOSONAR
    enc.setChunkSize(Biff8DecryptingStream.RC4_REKEYING_INTERVAL);
    byte tmp[] = new byte[1024];
    try {
        ChunkedCipherOutputStream os = enc.getDataStream(leos, initialOffset);
        int totalBytes = 0;
        while (totalBytes < buf.length) {
            plain.read(tmp, 0, 4);
            final int sid = LittleEndian.getUShort(tmp, 0);
            final int len = LittleEndian.getUShort(tmp, 2);
            boolean isPlain = Biff8DecryptingStream.isNeverEncryptedRecord(sid);
            os.setNextRecordSize(len, isPlain);
            os.writePlain(tmp, 0, 4);
            if (sid == BoundSheetRecord.sid) {
                // special case for the field_1_position_of_BOF (=lbPlyPos) field of
                // the BoundSheet8 record which must be unencrypted
                byte bsrBuf[] = new byte[len];
                plain.readFully(bsrBuf);
                os.writePlain(bsrBuf, 0, 4);
                os.write(bsrBuf, 4, len-4);
            } else {
                int todo = len;
                while (todo > 0) {
                    int nextLen = Math.min(todo, tmp.length);
                    plain.readFully(tmp, 0, nextLen);
                    if (isPlain) {
                        os.writePlain(tmp, 0, nextLen);
                    } else {
                        os.write(tmp, 0, nextLen);
                    }
                    todo -= nextLen;
                }
            }
            totalBytes += 4 + len;
        }
        os.close();
    } catch (Exception e) {
        throw new EncryptedDocumentException(e);
    }
}
 
Example #17
Source File: UserModelEventListener.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void processRecord( Record record ) {
	switch (record.getSid()) {
	
	case BOFRecord.sid:
		BOFRecord bof = (BOFRecord) record;
		//顺序进入新的Workbook  
		if (bof.getType() == bof.TYPE_WORKBOOK) {
			logger.debug( debugger, ">>>>>>>>>>开始解析excel 文档.....");
		//顺序进入新的Worksheet,因为Event API不会把Excel文件里的所有数据结构都关联起来,
		//所以这儿一定要记录现在进入第几个sheet了。
		} else if (bof.getType() == bof.TYPE_WORKSHEET) {
			//读取新的一个Sheet页
			logger.debug( debugger, ">>>>>>>>>>开始解析sheet页面内容...");
			sheetNo++;
			currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		break;
    //开始解析Sheet的信息,记录sheet,这儿会把所有的sheet都顺序打印出来,如果有多个sheet的话,可以顺序记入到一个List里   
	case BoundSheetRecord.sid:
		BoundSheetRecord bsr = (BoundSheetRecord) record;
		logger.debug( debugger, ">>>>>>>>>>New sheet named: " + bsr.getSheetname());
		break;
	//执行行记录事件
	case RowRecord.sid:
		RowRecord rowrec = (RowRecord) record;
		logger.debug( debugger, ">>>>>>>>>>记录开始, first column at "
				+ rowrec.getFirstCol() + " last column at "
				+ rowrec.getLastCol());
		break;
	// SSTRecords store a array of unique strings used in Excel.
	case SSTRecord.sid:
		sstrec = (SSTRecord) record;
		for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
			logger.debug( debugger, ">>>>>>>>>>String table value " + k + " = "
					+ sstrec.getString(k));
		}
		break;
		
	//发现数字类型的cell,因为数字和日期都是用这个格式,所以下面一定要判断是不是日期格式,另外默认的数字也会被视为日期格式,所以如果是数字的话,一定要明确指定格式!!!!!!!   
	case NumberRecord.sid:
			NumberRecord nr = (NumberRecord) record;
			//HSSFDateUtil.isInternalDateFormat(nr.getXFIndex())  判断是否为时间列
			int column=nr.getColumn();
			if(column==5||column==6){
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),getTime(nr.getValue()), debugger);
			}else{
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),(int)nr.getValue(), debugger);
			}
			break;
	//发现字符串类型,这儿要取字符串的值的话,跟据其index去字符串表里读取   
	case LabelSSTRecord.sid:
		LabelSSTRecord lsr = (LabelSSTRecord)record; 
		addDataAndrChangeRow(lsr.getRow(),lsr.getColumn(), sstrec.getString(lsr.getSSTIndex()), debugger);
		logger.debug( debugger, ">>>>>>>>>>文字列:"+sstrec.getString(lsr.getSSTIndex())+", 行:"+lsr.getRow()+", 列:"+lsr.getColumn());   
		break;
    case BoolErrRecord.sid: //解析boolean错误信息
           BoolErrRecord ber = (BoolErrRecord)record;   
           if(ber.isBoolean()){   
           	addDataAndrChangeRow(ber.getRow(),ber.getColumn(), ber.getBooleanValue(), debugger);
           	logger.debug( debugger, ">>>>>>>>>>Boolean:"+ber.getBooleanValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           if(ber.isError()){   
           	logger.debug( debugger, ">>>>>>>>>>Error:"+ber.getErrorValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           break;   
        //空白记录的信息
       case BlankRecord.sid: 
           BlankRecord br = (BlankRecord)record;   
           addDataAndrChangeRow(br.getRow(),br.getColumn(), "", debugger);
           logger.debug( debugger, ">>>>>>>>>>空。 行:"+br.getRow()+", 列:"+br.getColumn());   
           break;   
       case FormulaRecord.sid: //数式   
           FormulaRecord fr = (FormulaRecord)record;  
           addDataAndrChangeRow(fr.getRow(),fr.getColumn(), fr.getValue(), debugger);
           logger.debug( debugger, ">>>>>>>>>>数字 。 行:"+fr.getRow()+", 列:"+fr.getColumn());  
           break;  
	}
}
 
Example #18
Source File: UserModelEventListener.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void processRecord( Record record ) {
	switch (record.getSid()) {
	
	case BOFRecord.sid:
		BOFRecord bof = (BOFRecord) record;
		//顺序进入新的Workbook  
		if (bof.getType() == bof.TYPE_WORKBOOK) {
			logger.debug( debugger, ">>>>>>>>>>开始解析excel 文档.....");
		//顺序进入新的Worksheet,因为Event API不会把Excel文件里的所有数据结构都关联起来,
		//所以这儿一定要记录现在进入第几个sheet了。
		} else if (bof.getType() == bof.TYPE_WORKSHEET) {
			//读取新的一个Sheet页
			logger.debug( debugger, ">>>>>>>>>>开始解析sheet页面内容...");
			sheetNo++;
			currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		break;
    //开始解析Sheet的信息,记录sheet,这儿会把所有的sheet都顺序打印出来,如果有多个sheet的话,可以顺序记入到一个List里   
	case BoundSheetRecord.sid:
		BoundSheetRecord bsr = (BoundSheetRecord) record;
		logger.debug( debugger, ">>>>>>>>>>New sheet named: " + bsr.getSheetname());
		break;
	//执行行记录事件
	case RowRecord.sid:
		RowRecord rowrec = (RowRecord) record;
		logger.debug( debugger, ">>>>>>>>>>记录开始, first column at "
				+ rowrec.getFirstCol() + " last column at "
				+ rowrec.getLastCol());
		break;
	// SSTRecords store a array of unique strings used in Excel.
	case SSTRecord.sid:
		sstrec = (SSTRecord) record;
		for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
			logger.debug( debugger, ">>>>>>>>>>String table value " + k + " = "
					+ sstrec.getString(k));
		}
		break;
		
	//发现数字类型的cell,因为数字和日期都是用这个格式,所以下面一定要判断是不是日期格式,另外默认的数字也会被视为日期格式,所以如果是数字的话,一定要明确指定格式!!!!!!!   
	case NumberRecord.sid:
			NumberRecord nr = (NumberRecord) record;
			//HSSFDateUtil.isInternalDateFormat(nr.getXFIndex())  判断是否为时间列
			int column=nr.getColumn();
			if(column==5||column==6){
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),getTime(nr.getValue()), debugger);
			}else{
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),(int)nr.getValue(), debugger);
			}
			break;
	//发现字符串类型,这儿要取字符串的值的话,跟据其index去字符串表里读取   
	case LabelSSTRecord.sid:
		LabelSSTRecord lsr = (LabelSSTRecord)record; 
		addDataAndrChangeRow(lsr.getRow(),lsr.getColumn(), sstrec.getString(lsr.getSSTIndex()), debugger);
		logger.debug( debugger, ">>>>>>>>>>文字列:"+sstrec.getString(lsr.getSSTIndex())+", 行:"+lsr.getRow()+", 列:"+lsr.getColumn());   
		break;
    case BoolErrRecord.sid: //解析boolean错误信息
           BoolErrRecord ber = (BoolErrRecord)record;   
           if(ber.isBoolean()){   
           	addDataAndrChangeRow(ber.getRow(),ber.getColumn(), ber.getBooleanValue(), debugger);
           	logger.debug( debugger, ">>>>>>>>>>Boolean:"+ber.getBooleanValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           if(ber.isError()){   
           	logger.debug( debugger, ">>>>>>>>>>Error:"+ber.getErrorValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           break;   
        //空白记录的信息
       case BlankRecord.sid: 
           BlankRecord br = (BlankRecord)record;   
           addDataAndrChangeRow(br.getRow(),br.getColumn(), "", debugger);
           logger.debug( debugger, ">>>>>>>>>>空。 行:"+br.getRow()+", 列:"+br.getColumn());   
           break;   
       case FormulaRecord.sid: //数式   
           FormulaRecord fr = (FormulaRecord)record;  
           addDataAndrChangeRow(fr.getRow(),fr.getColumn(), fr.getValue(), debugger);
           logger.debug( debugger, ">>>>>>>>>>数字 。 行:"+fr.getRow()+", 列:"+fr.getColumn());  
           break;  
	}
}
 
Example #19
Source File: UserModelEventListener.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({ "static-access", "unused" })
@Override
public void processRecord(org.apache.poi.hssf.record.Record record) {
	switch (record.getSid()) {
	
	case BOFRecord.sid:
		BOFRecord bof = (BOFRecord) record;
		//顺序进入新的Workbook  
		if (bof.getType() == bof.TYPE_WORKBOOK) {
			//logger.debug( "开始解析excel 文档....." );
		//顺序进入新的Worksheet,因为Event API不会把Excel文件里的所有数据结构都关联起来,
		//所以这儿一定要记录现在进入第几个sheet了。
		} else if (bof.getType() == bof.TYPE_WORKSHEET) {
			//读取新的一个Sheet页
			//logger.debug( "开始解析sheet页面内容..." );
			//System.out.println( "sheetNo="+sheetNo);
			sheetNo++;
			currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		break;
    //开始解析Sheet的信息,记录sheet,这儿会把所有的sheet都顺序打印出来,如果有多个sheet的话,可以顺序记入到一个List里   
	case BoundSheetRecord.sid:
		BoundSheetRecord bsr = (BoundSheetRecord) record;
		//System.out.println( "sheetName="+bsr.getSheetname());
		//logger.debug( "New sheet named: " + bsr.getSheetname());
		break;
	//执行行记录事件
	case RowRecord.sid:
		RowRecord rowrec = (RowRecord) record;
		//logger.debug( "记录开始, first column at "
		//		+ rowrec.getFirstCol() + " last column at "
		//		+ rowrec.getLastCol());
		break;
	// SSTRecords store a array of unique strings used in Excel.
	case SSTRecord.sid:
		sstrec = (SSTRecord) record;
		for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
			//logger.debug( "String table value " + k + " = "
			//		+ sstrec.getString(k));
		}
		break;
		
	//发现数字类型的cell,因为数字和日期都是用这个格式,所以下面一定要判断是不是日期格式,另外默认的数字也会被视为日期格式,所以如果是数字的话,一定要明确指定格式!!!!!!!   
	case NumberRecord.sid:
			NumberRecord nr = (NumberRecord) record;
			//HSSFDateUtil.isInternalDateFormat(nr.getXFIndex())  判断是否为时间列
			int column=nr.getColumn();
			if(column==5||column==6){
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),getTime(nr.getValue()));
			}else{
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),(int)nr.getValue());
			}
			break;
	//发现字符串类型,这儿要取字符串的值的话,跟据其index去字符串表里读取   
	case LabelSSTRecord.sid:
		LabelSSTRecord lsr = (LabelSSTRecord)record; 
		addDataAndrChangeRow(lsr.getRow(),lsr.getColumn(), sstrec.getString(lsr.getSSTIndex()));
		//logger.debug( "文字列:"+sstrec.getString(lsr.getSSTIndex())+", 行:"+lsr.getRow()+", 列:"+lsr.getColumn());   
		break;
    case BoolErrRecord.sid: //解析boolean错误信息
           BoolErrRecord ber = (BoolErrRecord)record;   
           if(ber.isBoolean()){   
           	addDataAndrChangeRow(ber.getRow(),ber.getColumn(), ber.getBooleanValue());
           	//logger.debug( "Boolean:"+ber.getBooleanValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           if(ber.isError()){   
           	//logger.debug( "Error:"+ber.getErrorValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           break;   
        //空白记录的信息
       case BlankRecord.sid: 
           BlankRecord br = (BlankRecord)record;   
           addDataAndrChangeRow(br.getRow(),br.getColumn(), "" );
           //logger.debug( "空。 行:"+br.getRow()+", 列:"+br.getColumn());   
           break;   
       case FormulaRecord.sid: //数式   
           FormulaRecord fr = (FormulaRecord)record;  
           addDataAndrChangeRow(fr.getRow(),fr.getColumn(), fr.getValue());
           //logger.debug( "数字 。 行:"+fr.getRow()+", 列:"+fr.getColumn());  
           break;  
	}
}
 
Example #20
Source File: UserModelEventListener.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({ "static-access", "unused" })
@Override
public void processRecord(org.apache.poi.hssf.record.Record record) {
	switch (record.getSid()) {
	
	case BOFRecord.sid:
		BOFRecord bof = (BOFRecord) record;
		//顺序进入新的Workbook  
		if (bof.getType() == bof.TYPE_WORKBOOK) {
			//logger.debug( "开始解析excel 文档....." );
		//顺序进入新的Worksheet,因为Event API不会把Excel文件里的所有数据结构都关联起来,
		//所以这儿一定要记录现在进入第几个sheet了。
		} else if (bof.getType() == bof.TYPE_WORKSHEET) {
			//读取新的一个Sheet页
			//logger.debug( "开始解析sheet页面内容..." );
			//System.out.println( "sheetNo="+sheetNo);
			sheetNo++;
			currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		break;
    //开始解析Sheet的信息,记录sheet,这儿会把所有的sheet都顺序打印出来,如果有多个sheet的话,可以顺序记入到一个List里   
	case BoundSheetRecord.sid:
		BoundSheetRecord bsr = (BoundSheetRecord) record;
		//System.out.println( "sheetName="+bsr.getSheetname());
		//logger.debug( "New sheet named: " + bsr.getSheetname());
		break;
	//执行行记录事件
	case RowRecord.sid:
		RowRecord rowrec = (RowRecord) record;
		//logger.debug( "记录开始, first column at "
		//		+ rowrec.getFirstCol() + " last column at "
		//		+ rowrec.getLastCol());
		break;
	// SSTRecords store a array of unique strings used in Excel.
	case SSTRecord.sid:
		sstrec = (SSTRecord) record;
		for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
			//logger.debug( "String table value " + k + " = "
			//		+ sstrec.getString(k));
		}
		break;
		
	//发现数字类型的cell,因为数字和日期都是用这个格式,所以下面一定要判断是不是日期格式,另外默认的数字也会被视为日期格式,所以如果是数字的话,一定要明确指定格式!!!!!!!   
	case NumberRecord.sid:
			NumberRecord nr = (NumberRecord) record;
			//HSSFDateUtil.isInternalDateFormat(nr.getXFIndex())  判断是否为时间列
			int column=nr.getColumn();
			if(column==5||column==6){
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),getTime(nr.getValue()));
			}else{
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),(int)nr.getValue());
			}
			break;
	//发现字符串类型,这儿要取字符串的值的话,跟据其index去字符串表里读取   
	case LabelSSTRecord.sid:
		LabelSSTRecord lsr = (LabelSSTRecord)record; 
		addDataAndrChangeRow(lsr.getRow(),lsr.getColumn(), sstrec.getString(lsr.getSSTIndex()));
		//logger.debug( "文字列:"+sstrec.getString(lsr.getSSTIndex())+", 行:"+lsr.getRow()+", 列:"+lsr.getColumn());   
		break;
    case BoolErrRecord.sid: //解析boolean错误信息
           BoolErrRecord ber = (BoolErrRecord)record;   
           if(ber.isBoolean()){   
           	addDataAndrChangeRow(ber.getRow(),ber.getColumn(), ber.getBooleanValue());
           	//logger.debug( "Boolean:"+ber.getBooleanValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           if(ber.isError()){   
           	//logger.debug( "Error:"+ber.getErrorValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           break;   
        //空白记录的信息
       case BlankRecord.sid: 
           BlankRecord br = (BlankRecord)record;   
           addDataAndrChangeRow(br.getRow(),br.getColumn(), "" );
           //logger.debug( "空。 行:"+br.getRow()+", 列:"+br.getColumn());   
           break;   
       case FormulaRecord.sid: //数式   
           FormulaRecord fr = (FormulaRecord)record;  
           addDataAndrChangeRow(fr.getRow(),fr.getColumn(), fr.getValue());
           //logger.debug( "数字 。 行:"+fr.getRow()+", 列:"+fr.getColumn());  
           break;  
	}
}
 
Example #21
Source File: UserModelEventListener.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({ "static-access", "unused" })
@Override
public void processRecord(org.apache.poi.hssf.record.Record record) {
	switch (record.getSid()) {
	
	case BOFRecord.sid:
		BOFRecord bof = (BOFRecord) record;
		//顺序进入新的Workbook  
		if (bof.getType() == bof.TYPE_WORKBOOK) {
			//logger.debug( "开始解析excel 文档....." );
		//顺序进入新的Worksheet,因为Event API不会把Excel文件里的所有数据结构都关联起来,
		//所以这儿一定要记录现在进入第几个sheet了。
		} else if (bof.getType() == bof.TYPE_WORKSHEET) {
			//读取新的一个Sheet页
			//logger.debug( "开始解析sheet页面内容..." );
			//System.out.println( "sheetNo="+sheetNo);
			sheetNo++;
			currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		break;
    //开始解析Sheet的信息,记录sheet,这儿会把所有的sheet都顺序打印出来,如果有多个sheet的话,可以顺序记入到一个List里   
	case BoundSheetRecord.sid:
		BoundSheetRecord bsr = (BoundSheetRecord) record;
		//System.out.println( "sheetName="+bsr.getSheetname());
		//logger.debug( "New sheet named: " + bsr.getSheetname());
		break;
	//执行行记录事件
	case RowRecord.sid:
		RowRecord rowrec = (RowRecord) record;
		//logger.debug( "记录开始, first column at "
		//		+ rowrec.getFirstCol() + " last column at "
		//		+ rowrec.getLastCol());
		break;
	// SSTRecords store a array of unique strings used in Excel.
	case SSTRecord.sid:
		sstrec = (SSTRecord) record;
		for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
			//logger.debug( "String table value " + k + " = "
			//		+ sstrec.getString(k));
		}
		break;
		
	//发现数字类型的cell,因为数字和日期都是用这个格式,所以下面一定要判断是不是日期格式,另外默认的数字也会被视为日期格式,所以如果是数字的话,一定要明确指定格式!!!!!!!   
	case NumberRecord.sid:
			NumberRecord nr = (NumberRecord) record;
			//HSSFDateUtil.isInternalDateFormat(nr.getXFIndex())  判断是否为时间列
			int column=nr.getColumn();
			if(column==5||column==6){
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),getTime(nr.getValue()));
			}else{
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),(int)nr.getValue());
			}
			break;
	//发现字符串类型,这儿要取字符串的值的话,跟据其index去字符串表里读取   
	case LabelSSTRecord.sid:
		LabelSSTRecord lsr = (LabelSSTRecord)record; 
		addDataAndrChangeRow(lsr.getRow(),lsr.getColumn(), sstrec.getString(lsr.getSSTIndex()));
		//logger.debug( "文字列:"+sstrec.getString(lsr.getSSTIndex())+", 行:"+lsr.getRow()+", 列:"+lsr.getColumn());   
		break;
    case BoolErrRecord.sid: //解析boolean错误信息
           BoolErrRecord ber = (BoolErrRecord)record;   
           if(ber.isBoolean()){   
           	addDataAndrChangeRow(ber.getRow(),ber.getColumn(), ber.getBooleanValue());
           	//logger.debug( "Boolean:"+ber.getBooleanValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           if(ber.isError()){   
           	//logger.debug( "Error:"+ber.getErrorValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           break;   
        //空白记录的信息
       case BlankRecord.sid: 
           BlankRecord br = (BlankRecord)record;   
           addDataAndrChangeRow(br.getRow(),br.getColumn(), "" );
           //logger.debug( "空。 行:"+br.getRow()+", 列:"+br.getColumn());   
           break;   
       case FormulaRecord.sid: //数式   
           FormulaRecord fr = (FormulaRecord)record;  
           addDataAndrChangeRow(fr.getRow(),fr.getColumn(), fr.getValue());
           //logger.debug( "数字 。 行:"+fr.getRow()+", 列:"+fr.getColumn());  
           break;  
	}
}
 
Example #22
Source File: UserModelEventListener.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({ "static-access", "unused" })
@Override
public void processRecord(org.apache.poi.hssf.record.Record record) {
	switch (record.getSid()) {
	
	case BOFRecord.sid:
		BOFRecord bof = (BOFRecord) record;
		//顺序进入新的Workbook  
		if (bof.getType() == bof.TYPE_WORKBOOK) {
			//logger.debug( "开始解析excel 文档....." );
		//顺序进入新的Worksheet,因为Event API不会把Excel文件里的所有数据结构都关联起来,
		//所以这儿一定要记录现在进入第几个sheet了。
		} else if (bof.getType() == bof.TYPE_WORKSHEET) {
			//读取新的一个Sheet页
			//logger.debug( "开始解析sheet页面内容..." );
			//System.out.println( "sheetNo="+sheetNo);
			sheetNo++;
			currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		break;
    //开始解析Sheet的信息,记录sheet,这儿会把所有的sheet都顺序打印出来,如果有多个sheet的话,可以顺序记入到一个List里   
	case BoundSheetRecord.sid:
		BoundSheetRecord bsr = (BoundSheetRecord) record;
		//System.out.println( "sheetName="+bsr.getSheetname());
		//logger.debug( "New sheet named: " + bsr.getSheetname());
		break;
	//执行行记录事件
	case RowRecord.sid:
		RowRecord rowrec = (RowRecord) record;
		//logger.debug( "记录开始, first column at "
		//		+ rowrec.getFirstCol() + " last column at "
		//		+ rowrec.getLastCol());
		break;
	// SSTRecords store a array of unique strings used in Excel.
	case SSTRecord.sid:
		sstrec = (SSTRecord) record;
		for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
			//logger.debug( "String table value " + k + " = "
			//		+ sstrec.getString(k));
		}
		break;
		
	//发现数字类型的cell,因为数字和日期都是用这个格式,所以下面一定要判断是不是日期格式,另外默认的数字也会被视为日期格式,所以如果是数字的话,一定要明确指定格式!!!!!!!   
	case NumberRecord.sid:
			NumberRecord nr = (NumberRecord) record;
			//HSSFDateUtil.isInternalDateFormat(nr.getXFIndex())  判断是否为时间列
			int column=nr.getColumn();
			if(column==5||column==6){
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),getTime(nr.getValue()));
			}else{
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),(int)nr.getValue());
			}
			break;
	//发现字符串类型,这儿要取字符串的值的话,跟据其index去字符串表里读取   
	case LabelSSTRecord.sid:
		LabelSSTRecord lsr = (LabelSSTRecord)record; 
		addDataAndrChangeRow(lsr.getRow(),lsr.getColumn(), sstrec.getString(lsr.getSSTIndex()));
		//logger.debug( "文字列:"+sstrec.getString(lsr.getSSTIndex())+", 行:"+lsr.getRow()+", 列:"+lsr.getColumn());   
		break;
    case BoolErrRecord.sid: //解析boolean错误信息
           BoolErrRecord ber = (BoolErrRecord)record;   
           if(ber.isBoolean()){   
           	addDataAndrChangeRow(ber.getRow(),ber.getColumn(), ber.getBooleanValue());
           	//logger.debug( "Boolean:"+ber.getBooleanValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           if(ber.isError()){   
           	//logger.debug( "Error:"+ber.getErrorValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           break;   
        //空白记录的信息
       case BlankRecord.sid: 
           BlankRecord br = (BlankRecord)record;   
           addDataAndrChangeRow(br.getRow(),br.getColumn(), "" );
           //logger.debug( "空。 行:"+br.getRow()+", 列:"+br.getColumn());   
           break;   
       case FormulaRecord.sid: //数式   
           FormulaRecord fr = (FormulaRecord)record;  
           addDataAndrChangeRow(fr.getRow(),fr.getColumn(), fr.getValue());
           //logger.debug( "数字 。 行:"+fr.getRow()+", 列:"+fr.getColumn());  
           break;  
	}
}
 
Example #23
Source File: UserModelEventListener.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({ "static-access", "unused" })
@Override
public void processRecord(org.apache.poi.hssf.record.Record record) {
	switch (record.getSid()) {
	
	case BOFRecord.sid:
		BOFRecord bof = (BOFRecord) record;
		//顺序进入新的Workbook  
		if (bof.getType() == bof.TYPE_WORKBOOK) {
			//logger.debug( "开始解析excel 文档....." );
		//顺序进入新的Worksheet,因为Event API不会把Excel文件里的所有数据结构都关联起来,
		//所以这儿一定要记录现在进入第几个sheet了。
		} else if (bof.getType() == bof.TYPE_WORKSHEET) {
			//读取新的一个Sheet页
			//logger.debug( "开始解析sheet页面内容..." );
			//System.out.println( "sheetNo="+sheetNo);
			sheetNo++;
			currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		break;
    //开始解析Sheet的信息,记录sheet,这儿会把所有的sheet都顺序打印出来,如果有多个sheet的话,可以顺序记入到一个List里   
	case BoundSheetRecord.sid:
		BoundSheetRecord bsr = (BoundSheetRecord) record;
		//System.out.println( "sheetName="+bsr.getSheetname());
		//logger.debug( "New sheet named: " + bsr.getSheetname());
		break;
	//执行行记录事件
	case RowRecord.sid:
		RowRecord rowrec = (RowRecord) record;
		//logger.debug( "记录开始, first column at "
		//		+ rowrec.getFirstCol() + " last column at "
		//		+ rowrec.getLastCol());
		break;
	// SSTRecords store a array of unique strings used in Excel.
	case SSTRecord.sid:
		sstrec = (SSTRecord) record;
		for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) {
			//logger.debug( "String table value " + k + " = "
			//		+ sstrec.getString(k));
		}
		break;
		
	//发现数字类型的cell,因为数字和日期都是用这个格式,所以下面一定要判断是不是日期格式,另外默认的数字也会被视为日期格式,所以如果是数字的话,一定要明确指定格式!!!!!!!   
	case NumberRecord.sid:
			NumberRecord nr = (NumberRecord) record;
			//HSSFDateUtil.isInternalDateFormat(nr.getXFIndex())  判断是否为时间列
			int column=nr.getColumn();
			if(column==5||column==6){
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),getTime(nr.getValue()));
			}else{
				addDataAndrChangeRow(nr.getRow(),nr.getColumn(),(int)nr.getValue());
			}
			break;
	//发现字符串类型,这儿要取字符串的值的话,跟据其index去字符串表里读取   
	case LabelSSTRecord.sid:
		LabelSSTRecord lsr = (LabelSSTRecord)record; 
		addDataAndrChangeRow(lsr.getRow(),lsr.getColumn(), sstrec.getString(lsr.getSSTIndex()));
		//logger.debug( "文字列:"+sstrec.getString(lsr.getSSTIndex())+", 行:"+lsr.getRow()+", 列:"+lsr.getColumn());   
		break;
    case BoolErrRecord.sid: //解析boolean错误信息
           BoolErrRecord ber = (BoolErrRecord)record;   
           if(ber.isBoolean()){   
           	addDataAndrChangeRow(ber.getRow(),ber.getColumn(), ber.getBooleanValue());
           	//logger.debug( "Boolean:"+ber.getBooleanValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           if(ber.isError()){   
           	//logger.debug( "Error:"+ber.getErrorValue()+", 行:"+ber.getRow()+", 列:"+ber.getColumn());   
           }   
           break;   
        //空白记录的信息
       case BlankRecord.sid: 
           BlankRecord br = (BlankRecord)record;   
           addDataAndrChangeRow(br.getRow(),br.getColumn(), "" );
           //logger.debug( "空。 行:"+br.getRow()+", 列:"+br.getColumn());   
           break;   
       case FormulaRecord.sid: //数式   
           FormulaRecord fr = (FormulaRecord)record;  
           addDataAndrChangeRow(fr.getRow(),fr.getColumn(), fr.getValue());
           //logger.debug( "数字 。 行:"+fr.getRow()+", 列:"+fr.getColumn());  
           break;  
	}
}
 
Example #24
Source File: XlsReadWorkbookHolder.java    From easyexcel with Apache License 2.0 4 votes vote down vote up
public void setBoundSheetRecordList(List<BoundSheetRecord> boundSheetRecordList) {
    this.boundSheetRecordList = boundSheetRecordList;
}
 
Example #25
Source File: XlsReadWorkbookHolder.java    From easyexcel with Apache License 2.0 4 votes vote down vote up
public List<BoundSheetRecord> getBoundSheetRecordList() {
    return boundSheetRecordList;
}
 
Example #26
Source File: BoundSheetRecordHandler.java    From easyexcel with Apache License 2.0 4 votes vote down vote up
@Override
public void processRecord(XlsReadContext xlsReadContext, Record record) {
    BoundSheetRecord bsr = (BoundSheetRecord)record;
    xlsReadContext.xlsReadWorkbookHolder().getBoundSheetRecordList().add((BoundSheetRecord)record);
}
 
Example #27
Source File: EventWorkbookBuilder.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a stub workbook from the supplied records,
 *  suitable for use with the {@link HSSFFormulaParser}
 * @param externs The ExternSheetRecords in your file
 * @param bounds The BoundSheetRecords in your file
 * @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
 */
public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs,
		BoundSheetRecord[] bounds) {
	return createStubWorkbook(externs, bounds, null);
}
 
Example #28
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Hide or unhide a sheet.
 *
 * @param sheetnum   The sheet number
 * @param visibility the sheet visibility to set (visible, hidden, very hidden)
 * @since 3.16 beta 2
 */
public void setSheetHidden(int sheetnum, SheetVisibility visibility) {
    BoundSheetRecord bsr = getBoundSheetRec(sheetnum);
    bsr.setHidden(visibility == SheetVisibility.HIDDEN);
    bsr.setVeryHidden(visibility == SheetVisibility.VERY_HIDDEN);
}
 
Example #29
Source File: InternalWorkbook.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * create a "bound sheet" or "bundlesheet" (depending who you ask) record
 * Always sets the sheet's bof to 0.  You'll need to set that yourself.
 * @param id either sheet 0,1 or 2.
 * @return record containing a BoundSheetRecord
 * @see org.apache.poi.hssf.record.BoundSheetRecord
 * @see org.apache.poi.hssf.record.Record
 */
private static BoundSheetRecord createBoundSheet(int id) {
    return new BoundSheetRecord("Sheet" + (id+1));
}