apache-poi

Cell formatting to remove decimal point in excel cell when data Writing Using Apache POI

我的梦境 提交于 2020-02-02 22:58:19
问题 I'm using Apache POI to Write a Excel function into a cell and evaluate the function. What i need to do is to remove all decimal points from the cell.Currently it getting unnecessary two Zeros at the end of each cell values.The cell formatting as follows. But it is always getting two zeros at the end. XSSFCellStyle cellStyle = cell.getCellStyle(); DataFormat df = workbook.createDataFormat(); cellStyle.setDataFormat(df.getFormat("###,##0")); cell.setCellStyle(cellStyle); if (cell.getCellType()

Apache Poi: get page count in DOC document

 ̄綄美尐妖づ 提交于 2020-01-30 12:08:43
问题 How to get page count in DOC document using Apache Poi? I try to use the following piece of code: HWPFDocument wordDoc = new HWPFDocument(new FileInputStream(lowerFilePath)); Integer pageCount = wordDoc.getSummaryInformation().getPageCount(); But got exception (version of Apache Poi: 3.13) java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.toByteArray(Ljava/io/InputStream;I)[B at org.apache.poi.hwpf.HWPFDocumentCore.verifyAndBuildPOIFS(HWPFDocumentCore.java:95) at org.apache.poi.hwpf

Apache Poi: get page count in DOC document

点点圈 提交于 2020-01-30 12:07:26
问题 How to get page count in DOC document using Apache Poi? I try to use the following piece of code: HWPFDocument wordDoc = new HWPFDocument(new FileInputStream(lowerFilePath)); Integer pageCount = wordDoc.getSummaryInformation().getPageCount(); But got exception (version of Apache Poi: 3.13) java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.toByteArray(Ljava/io/InputStream;I)[B at org.apache.poi.hwpf.HWPFDocumentCore.verifyAndBuildPOIFS(HWPFDocumentCore.java:95) at org.apache.poi.hwpf

Open .docx with Apache POI and save it with password

我的未来我决定 提交于 2020-01-30 11:34:06
问题 The goal is to open existing .docx document and save it encrypted with password. I use Apache POI library for that. The code below works fine and makes document encrypted and password protected. But after the file creating I can open it with the LibreOffice but can't with the MS Word or OpenOffice Writer. It seems that the file has no content type part cuz OpenOffice asked me about file's filter. But when I choosed "Microsoft Word 2007 XML" I got the "Common Input-Output error" from the

Java - NoClassDefFoundError XSSFWorkbook

ぃ、小莉子 提交于 2020-01-30 09:15:06
问题 I creating CSV to XLSX app - My first question Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook at com.test.csv2xlsx.Csv2Xlsx.<init>(Csv2Xlsx.java:35) at com.test.csv2xlsx.Csv2Xlsx.main(Csv2Xlsx.java:49) Caused by: java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbook at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass

How to insert a linebreak as the data of a cell?

为君一笑 提交于 2020-01-29 15:48:09
问题 I use Apache POI 3.16 to create an Excel file. I want to set the data inside a particular cell to have a linebreak : rowConsommationEtRealisation.createCell(0).setCellValue("Consommation (crédits)\r\nRéalisation (produits)"); When I open the file then the cell value does not have linebreak ! So how to create linebreak ? 回答1: Try this: here Row row = sheet.createRow(2); Cell cell = row.createCell(2); cell.setCellValue("Use \n with word wrap on to create a new line"); //to enable newlines you

POI reading excel strings as numeric

核能气质少年 提交于 2020-01-28 02:26:06
问题 I am using Apache POI for reading excel file. And while reading it I have noticed that it takes strings as float values. If my cell contains 1 then it will fetch it as 1.0 I took some hints from previous questions here and modified the code but still the float representation remains as it is. How would I read correctly the data for strings and dates? DataFormatter df = new DataFormatter(); for (Row row : sheet) { for(int cn=0; cn<row.getLastCellNum(); cn++) { // If the cell is missing from

POI reading excel strings as numeric

不羁的心 提交于 2020-01-28 02:25:14
问题 I am using Apache POI for reading excel file. And while reading it I have noticed that it takes strings as float values. If my cell contains 1 then it will fetch it as 1.0 I took some hints from previous questions here and modified the code but still the float representation remains as it is. How would I read correctly the data for strings and dates? DataFormatter df = new DataFormatter(); for (Row row : sheet) { for(int cn=0; cn<row.getLastCellNum(); cn++) { // If the cell is missing from

Reading equations from Word (*.docx) to HTML together with their text context using apache poi

走远了吗. 提交于 2020-01-25 06:52:27
问题 We are building a java code to read word document (.docx) into our program using apache POI . We are stuck when we encounter formulas and chemical equation inside the document. Yet, we managed to read formulas but we have no idea how to locate its index in concerned string.. INPUT (format is *.docx ) text before formulae **CHEMICAL EQUATION** text after OUTPUT (format shall be HTML ) we designed text before formulae text after **CHEMICAL EQUATION** We are unable to fetch the string and

Format Picture with Fill and Line using apache poi in Java

一曲冷凌霜 提交于 2020-01-24 21:56:07
问题 I am inserting image in excel using apache poi 3.15 its working file but I want to add border line to image which can be done by right click on image --> Format Picture --> Fill & Line --> Line --> Solid Line in MS Office searched a lot on SO and apache documentation but have no clue how to achieve this using poi. Following my code private void drawImageOnExcelSheetForGLOS(XSSFSheet sitePhotosSheet, int row1, int row2, int col1, int col2, String fileName) { try { InputStream is = new