Examples of HSSFWorkbook


Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

@Test
public class ExcelReaderTest {

  public void testReadCell() throws Exception {
    FileInputStream in = new FileInputStream("src/test/resources/date.xls");
    HSSFWorkbook wb = new HSSFWorkbook(in);
    HSSFCell dateCell = wb.getSheetAt(0).getRow(0).getCell(0);
    HSSFCell dateTimeCell = wb.getSheetAt(0).getRow(0).getCell(1);
    Object value = ExcelItemReader.getCellValue(dateCell);
    Assert.assertTrue(value instanceof Date);
    Object value2 = ExcelItemReader.getCellValue(dateTimeCell);
    Assert.assertTrue(value2 instanceof Date);
    in.close();
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

  public ExcelTools() {
  }

  public HSSFWorkbook toExcel(Collection<Object[]> datas, String propertyShowKeys) throws Exception {
    // 建立新HSSFWorkbook对象
    HSSFWorkbook wb = new HSSFWorkbook();
    return toExcel(wb, "export data", datas, propertyShowKeys);
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

   * @return 返回�?个HSSFWorkbook(excel)类型数�?.
   * @throws Exception
   */
  public <T> HSSFWorkbook object2Excel(Collection<T> list, String propertyKeys, String propertyShowKeys,
      PropertyExtractor exporter) throws Exception {
    HSSFWorkbook wb = new HSSFWorkbook(); // 建立新HSSFWorkbook对象
    object2Excel(wb, "export result", list, propertyKeys, propertyShowKeys, exporter);
    return wb;
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

  }


  protected void openWorkbook(OutputStream os)
  {
    workbook = new HSSFWorkbook();
    emptyCellStyle = workbook.createCellStyle();
    emptyCellStyle.setFillForegroundColor((new HSSFColor.WHITE()).getIndex());
    emptyCellStyle.setFillPattern(backgroundMode);
    dataFormat = workbook.createDataFormat();
    createHelper = workbook.getCreationHelper();
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

  private HSSFRow excelRow = null;
  private int row = 0;
  private int col = 0;

  public CsvBuilder() {
    excelWorkbook = new HSSFWorkbook();
    excelSheet = excelWorkbook.createSheet();
    excelRow = excelSheet.createRow(0);
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

    try {
      bis = new BufferedInputStream(leaf.getInputStream());
      StringBuilder content = new StringBuilder(bis.available());
      POIFSFileSystem fs = new POIFSFileSystem(bis);
      HSSFWorkbook workbook = new HSSFWorkbook(fs);

      for (int sheetNumber = 0; sheetNumber < workbook.getNumberOfSheets(); sheetNumber++) {
        HSSFSheet sheet = workbook.getSheetAt(sheetNumber);
        if (sheet != null) {
          for (int rowNumber = sheet.getFirstRowNum(); rowNumber <= sheet.getLastRowNum(); rowNumber++) {
            HSSFRow row = sheet.getRow(rowNumber);
            if (row != null) {
              for (int cellNumber = row.getFirstCellNum(); cellNumber <= row.getLastCellNum(); cellNumber++) {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

        try
        {
            poifs = new POIFSFileSystem( inStream );
           
            // Get the workbook for further references
            _workbook = new HSSFWorkbook(poifs);          
           
            // get the Workbook (excel part) stream in a InputStream
            din = poifs.createDocumentInputStream( WORKBOOK );
            HSSFRequest req = new HSSFRequest( );
            // lazy listen for ALL records with the listener shown above
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

    XSSFCellStyle style1 = wb1.createCellStyle();
        assertEquals(IndexedColors.AUTOMATIC.getIndex(), style1.getFillBackgroundColor());
        assertNull(style1.getFillBackgroundXSSFColor());

        //compatibility with HSSF
        HSSFWorkbook wb2 = new HSSFWorkbook();
        HSSFCellStyle style2 = wb2.createCellStyle();
        assertEquals(style2.getFillBackgroundColor(), style1.getFillBackgroundColor());
        assertEquals(style2.getFillForegroundColor(), style1.getFillForegroundColor());
        assertEquals(style2.getFillPattern(), style1.getFillPattern());

        assertEquals(style2.getLeftBorderColor(), style1.getLeftBorderColor());
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

     */
    public void test48718() throws Exception {
       // Verify the HSSF behaviour
       // Then ensure the same for XSSF
       Workbook[] wbs = new Workbook[] {
             new HSSFWorkbook(),
             new XSSFWorkbook()
       };
       int[] initialFonts = new int[] { 4, 1 };
       for(int i=0; i<wbs.length; i++) {
          Workbook wb = wbs[i];
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

     *  and with the docs on when fetching the wrong
     *  kind of value from a Formula cell
     */
    public void test47815() {
       Workbook[] wbs = new Workbook[] {
             new HSSFWorkbook(),
             new XSSFWorkbook()
       };
       for(Workbook wb : wbs) {
          Sheet s = wb.createSheet();
          Row r = s.createRow(0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.