apache-poi

xmlbeans could not locate schema resource when repacking xml beans jar into my own jar

匆匆过客 提交于 2019-12-11 06:35:44
问题 I am writing an application that needs to be contained in a jar. The program needs to validate and grab data from an excel spreadsheet. Therefore I am using the Apache POI libraries which are dependent on xmlbeans jar. My problem is that when I include the xmlbeans jar in my jar using ant <jar ... <zipfileset src="${xmlbeans.jar}" includes="**/*" /> Build and then run the jar, I get the following error: Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could

Excel file corrupt after writing

只愿长相守 提交于 2019-12-11 06:24:54
问题 I am using the 3.10 Version of POI. Problem I am running into is that I am creating a xls,xlsx file. All looks good when writing the file. It is about 2MB. When I open in excel it truncates the file to 4K and I only get my column headers all the data is gone. If I try to open as xlsx it says it is corrupt. Anyone else hit this problem. Here is the code that writes the row of data. public void writeRow(int irow, String[] rdata) { Row row; Cell cell; int cellnum = 0; int rownum = irow; System

Formula Evaluator in Apache POI

十年热恋 提交于 2019-12-11 06:22:01
问题 I have a program in which it pulls data from a workbook. One of the sheets has a cell in it that gets its data from a formula that involves another sheet from the same workbook. The workbook is called "week 11.xls" and the sheet is called Sat AP. I'm trying to use this code below: HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(myWorkbook); HSSFCell cell = myWorkbook.getSheetAt(11).getRow(10).getCell(3); CellValue cv = fe.evaluate(cell); I get the error that it cannot resolve the external

good way to represent a excel sheet value in Java

被刻印的时光 ゝ 提交于 2019-12-11 06:05:22
问题 Consider that I've a excel sheet in below format: person age Foo 29 Bar 27 Now I want to read these values (using POI HSSF) and have to process them. What's the best way to do that? Note that I do not have a Object Person in my application, becasue the values that may come in excel sheet is arbitrary (i.e. it may not be the person name and age). So, I need to use some kinda HashMap to store these values. In case multiple rows, is it good to have a List !? 回答1: public class Grid { private Row

How to read DOCX using Apache POI in page by page mode

前提是你 提交于 2019-12-11 06:05:17
问题 I would like to read a docx files to search for a particular text. I would like the program to print the page on which it was found and the document name. I have written this simple method, but it doesn't count any page: private static void searchDocx(File file, String searchText) throws IOException { FileInputStream fis = new FileInputStream(file.getAbsolutePath()); XWPFDocument document = new XWPFDocument(fis); int pageNo = 1; for (XWPFParagraph paragraph : document.getParagraphs()) {

Getting corrupted file while exporting .xls file using java/javascript and apache POI

情到浓时终转凉″ 提交于 2019-12-11 05:58:47
问题 I am trying to downlaod a .xls file in browser from a web application. Below is the code for the same. try(FileInputStream inputStream = new FileInputStream("C:\\Users\\Desktop\\Book1.xls")){ response.setContentType("application/vnd.ms-excel"); //response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=Book1.xls"); outputStream = response.getOutputStream(); byte[] buffer = new byte[BUFFERSIZE]

How to edit existing word file using POI API

痴心易碎 提交于 2019-12-11 05:51:18
问题 Using: XWPFDocument document = new XWPFDocument(); How do I assign it so it doesn't overwrite the file if it already exists? 回答1: The following will create a brand new, empty XWPF Word Document to work with: XWPFDocument document = new XWPFDocument(); Whereas this will open up an existing one for editing: XWPFDocument document = new XWPFDocument(OPCPackage.open("MyFile.docx")); Or if you have an InputStream rather than a file: XWPFDocument document = new XWPFDocument(inputStream); 来源: https:/

How to disable intermediate total using apache poi

冷暖自知 提交于 2019-12-11 05:20:41
问题 How to disable intermediate total using Apache poi, I'm using apache poi for this, i want intermediate total should be disabled Here is input in excel for understanding Expected result public class ApacheCreatePivotTable { public static void main(String[] args) throws Exception { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = (XSSFSheet) wb.createSheet(); //Create some data to build the pivot table on setCellData(sheet); // System.out.println(sheet.getRow(0).getLastCellNum());

Exception in thread “main” org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException

蹲街弑〆低调 提交于 2019-12-11 05:02:44
问题 I have the following jar files dom4j-1.6.1.jar poi-3.11.jar poi-ooxml-3.11.jar poi-ooxml-schemas-3.15-beta2.jar xmlbeans-2.6.0.jar poi-scratchpad-3.11.jar poi-excelant-3.11.jar and i'm trying to read an excel(2007) worksheet. My code is as follows import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache

How do I edit a PPTX file via Java while it is open in Microsoft PowerPoint?

穿精又带淫゛_ 提交于 2019-12-11 04:57:37
问题 With reference to POI - Cannot write to file while it is opened in Excel? The required functionality for my Java application under development is the PowerPoint version of the above: Using Java, create a slide and add content generated from captured application data, then add the slide to an existing PowerPoint file that is currently opened in Microsoft PowerPoint. If no PowerPoint file is opened, the Java application will first open Microsoft PowerPoint if necessary, then create a new, empty