FAQ Database Discussion Community


Getting specific data from an excel sheet JAVA

java,excel,apache,apache-poi,xssf
I am trying to get specific data from an excel sheet, The data is dynamic. It can be anything really. The column headers are the only things i can use for placeholders, but the column header positions can vary in the sheet. For example i have a sheet like this...

CellStyle dataformat for XLSX

java,apache-poi,export-to-excel,xssf,poi-hssf
I have some code like : CellStyle cs2 = wb.createCellStyle(); CellStyle cs4 = wb.createCellStyle(); cs4.setDataFormat(HSSFDataFormat.getBuiltinFormat("CELL_TYPE_NUMERIC")); cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text")); this is for creating xls reports. How do i change this code to create XLSX reports ? will the following work ? XSSFDataFormat format = (XSSFDataFormat) wb.createDataFormat(); cs2.setDataFormat(format.getFormat("text")); Please help. Thanks...

NoClassDefFoundError: UnsupportedFileFormatException while working with excel sheet using java

java,excel,apache-poi,xlsx,xssf
I'm writing a Java program which reads from a .xlsx file and give the output in .csv format. This is my code: import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.ss.usermodel.Cell;...

Apache POI XSSFFont getBold() give null pointer exception

java,apache,apache-poi,xlsx,xssf
I'm trying to check whether the font in excel is bold or not.I kept getting a null pointer exception everytime I run the code. XSSFSheet sheet1 = workbook.getSheetAt(1); XSSFRow row1 = sheet1.getRow(1); XSSFCell cell4 = row1.getCell(4); XSSFRichTextString val = cell4.getRichStringCellValue(); System.out.println(val.toString()); XSSFFont f = val.getFontAtIndex(0); System.out.println(f.getBold()); <--- this line is...

applying styles to a complete row using xssfworkbook in java

java,excel,xssf
Here,I am applying styles to excel,if I apply styles to individual cell it is working but takes lot of time to copy content and apply styles.Here we have option for applying styles to entire row at once using "row.setRowStyle(Style);" but styles are not applicable to excel. Here is the sample...

XSSFWorkbook, XSSFSheet not working - NetBeans 8.0.2

java,apache-poi,netbeans-8,xssf
I downloaded the POI 3.11 package from the Apache repositories website, added them to my project. After that I added xmlbeans, ooxml-schemas, but still my NetBeans 8.0.1 IDE shows an error when I declare XSSFWorkbook and XSSFSheet. Can anybody help me here as I am not much of a core...

XSSFWorkbook poi: adding image IOUtils toByteArray unfined error

apache-poi,xssf
To insert image to excel using POI:XSSF I am using maven poi dependency: <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.8</version> </dependency> AND code as : InputStream my_banner_image = new FileInputStream("input.png"); byte[] bytes = IOUtils.toByteArray(my_banner_image); int my_picture_id = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); I am getting these errors: 1) The method toByteArray(InputStream) is undefined for the type...