apache-poi

Cannot import XSSF in Apache POI

对着背影说爱祢 提交于 2019-12-17 07:14:08
问题 I am referencing the version 3.7 of the Apache POI and I am getting a "cannot be resolved" error when I do: import org.apache.poi.xssf.usermodel.XSSFWorkbook; Other import statements that reference POI DO NOT give me errors, such as: import org.apache.poi.ss.usermodel.*; Any ideas?? 回答1: For OOXML to work you need the POI-OOXML jar which is separately packaged from the POI jar. Download the POI-OOXML jar from the following location - http://repo1.maven.org/maven2/org/apache/poi/poi-ooxml/3.11

Exception when writing to the xlsx document several times using apache poi 3.7

耗尽温柔 提交于 2019-12-17 06:46:22
问题 I am getting the following exception while trying to write an .xlsx file using Apache POI: org.apache.xmlbeans.impl.values.XmlValueDisconnectedException It seems the problem is using the method write () second time. When working with a HSSFWorkbook of this problem does not arise. Here's the Code: public class SomeClass{ XSSFWorkbook workbook; public SomeClass() throws IOException{ File excelFile = new File("workbook.xlsx"); InputStream inp = new FileInputStream(excelFile); workbook = new

How to load a large xlsx file with Apache POI?

早过忘川 提交于 2019-12-17 03:57:20
问题 I have a large .xlsx file (141 MB, containing 293413 lines with 62 columns each) I need to perform some operations within. I am having problems with loading this file ( OutOfMemoryError ), as POI has a large memory footprint on XSSF (xlsx) workbooks. This SO question is similar, and the solution presented is to increase the VM's allocated/maximum memory. It seems to work for that kind of file-size (9MB), but for me, it just simply doesn't work even if a allocate all available system memory.

How to load a large xlsx file with Apache POI?

情到浓时终转凉″ 提交于 2019-12-17 03:57:11
问题 I have a large .xlsx file (141 MB, containing 293413 lines with 62 columns each) I need to perform some operations within. I am having problems with loading this file ( OutOfMemoryError ), as POI has a large memory footprint on XSSF (xlsx) workbooks. This SO question is similar, and the solution presented is to increase the VM's allocated/maximum memory. It seems to work for that kind of file-size (9MB), but for me, it just simply doesn't work even if a allocate all available system memory.

How to convert doc to pdf file using itext

*爱你&永不变心* 提交于 2019-12-16 18:04:06
问题 I need how to convert doc to pdf file using itext. I am using the following code it is not working. i am using itext 2.1.7.jar. The following error is coming: Exception in thread "main" ExceptionConverter: java.io.IOException: The document has no pages.at com.lowagie.text.pdf.PdfPages.writePageTree(Unknown Source) at com.lowagie.text.pdf.PdfWriter.close(Unknown Source) at com.lowagie.text.pdf.PdfDocument.close(Unknown Source) at com.lowagie.text.Document.close(Unknown Source) Here's my source

how to insert new rows with values in the same sheet of an excel file in java

≯℡__Kan透↙ 提交于 2019-12-14 03:46:50
问题 I want to insert new rows while writing in Excel sheet. Here is my code: public static void addValuesInWorkbook(String pathAndFileName, String sheetName, int rowNum, String valuesString,String delimeter) { if(pathAndFileName.length() > 0 && sheetName.length() > 0 && rowNum >= 0 && valuesString.length() > 0 && delimeter.length() > 0) { String[] colValues= null; if("|".equals(delimeter)) colValues = valuesString.split("\\|"); else colValues = valuesString.split(delimeter); int cellnum = 0;

How to generate different headers in first page and other pages in poi word XWPF?

邮差的信 提交于 2019-12-14 03:43:12
问题 I want to generate different headers in first page and other pages in poi word, So I used XWPFHeaderFooterPolicy.FIRST and XWPFHeaderFooterPolicy.DEFAULT. when I using XWPFHeaderFooterPolicy.DEFAULT I can insert my header successfully, but when I change to XWPFHeaderFooterPolicy.FIRST, I cannot see there is a header in my first page, this is my code in below, what's wrong with it? thanks! XWPFHeader header = headerFooterPolicy.createHeader(XWPFHeaderFooterPolicy.FIRST); paragraph = header

How to Read images from word(DOC) file and add it to pdf file?

天大地大妈咪最大 提交于 2019-12-14 03:35:27
问题 I have a doc file that contains text,images etc etc. Now I want to read that doc file and write those contents into pdf file. My DOC file and newly generated PDF file has to be same. I repeat, My DOC file contains ( "images as well as text" data ). If anyone have this code please help me out. Thank you so much for your time.. 回答1: You can use this code to get all the images from your document. HWPFDocument doc = new HWPFDocument(fs);// fs is the object of POIFSFileSystem Range range = doc

How to read doc file using Poi?

杀马特。学长 韩版系。学妹 提交于 2019-12-14 03:27:17
问题 I am trying to view word file in my editor pane I tried these lines import java.awt.Dimension; import java.awt.GridLayout; import java.io.File; import java.io.FileInputStream; import javax.swing.JEditorPane; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.extractor.WordExtractor; public class editorpane extends JEditorPane { public editorpane(File file) { try { FileInputStream fis = new FileInputStream(file.getAbsolutePath()); HWPFDocument hwpfd = new HWPFDocument(fis);

Get Image from the document using Apache POI

点点圈 提交于 2019-12-14 03:16:24
问题 I am using Apache Poi to read images from docx. Here is my code: enter code here public Image ReadImg(int imageid) throws IOException { XWPFDocument doc = new XWPFDocument(new FileInputStream("import.docx")); BufferedImage jpg = null; List<XWPFPictureData> pic = doc.getAllPictures(); XWPFPictureData pict = pic.get(imageid); String extract = pict.suggestFileExtension(); byte[] data = pict.getData(); //try to read image data using javax.imageio.* (JDK 1.4+) jpg = ImageIO.read(new