apache-poi

Read / Write different Microsoft Office file formats using Apache POI

断了今生、忘了曾经 提交于 2019-12-13 09:33:47
问题 How to perform different functions on Microsoft Excel spreadsheet using Apache POI ? I'm trying to generate and update an Excel file ( data from DB ) from my Spring MVC App.. Thanks 回答1: Include apache poi jar file <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.15</version> </dependency> To read an excel file import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; //.. FileInputStream file = new FileInputStream

How to read column a1 from an Excel sheet and perform string matching to define variables in a Java program

萝らか妹 提交于 2019-12-13 08:06:00
问题 I need to read one fixed column of an Excel sheet and from that column I need to find out the variables and load them into a Java program. For example I need to read column a1 which contains the following data: "What is /@v1@/% of /@v2@/?" /@v1@/ and /@v2@/ are the variables. My Java program needs to detect these variables and insert random values into them. I have done the following: import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; import org.apache.poi.hssf

Enable Filtering and sorting in a protected sheet using Apache POI

醉酒当歌 提交于 2019-12-13 07:57:23
问题 I have created a workbook with protected sheets because I only need a very few columns as editable. Although I want to let the user to be able to sort and filter columns. Google searches have failed me as of yet. Any kind of help will be appreciated. 回答1: If it is a XSSFSheet , then XSSFSheet.lockAutoFilter(false) and XSSFSheet.lockSort(false) will set the properties for enabling auto-filtering and sorting in protected sheets. Of course the auto-filter itself must be set before protecting the

AutoSizeColumn performance effect in Apache POI [duplicate]

丶灬走出姿态 提交于 2019-12-13 07:53:23
问题 This question already has answers here : A POI related code block running dead slow (2 answers) Closed 5 years ago . I am using Apache POI to create Excel sheets of some records. One such record has 16k rows. I am using a for loop to write records into the excel sheet and in each iteration I am using autoSizeColumn() to auto size the columns. This way I am not able to download/write to the excel file as it is taking forever to complete the writing process. While I was browsing SO, I came

how to get the excel workbook mathematical operators using apache poi 3.6?

早过忘川 提交于 2019-12-13 07:14:26
问题 In my application, i want to get all the operators that Excel WorkBook supports using apache poi 3.6... Please guide me to get this issue properly? Saravanan.P 回答1: All the functions that are implemented should be found in the org.apache.poi.ss.formula.functions package: http://poi.apache.org/apidocs/org/apache/poi/ss/formula/functions/package-summary.html FunctionEval holds the registration of all the functions, which may be the best place to see them all as a list: https://svn.apache.org

Apache POI characters run for .docx

天涯浪子 提交于 2019-12-13 06:48:53
问题 In .doc files, There is a function to get each character in paragraph by using CharacterRun charrun = paragraph.getCharacterRun(k++); and then I can use those character runs to inspect their attributes like if ( charrun.isBold() == true) System.out.print(charrun.text()); or something like that. But with .docx files seems to have no characters run method that can read each word like that, I tried to use XWPFParagraph item = paragraph.get(i); List<XWPFRun> charrun = item.getRuns(); I found that

get thumbnail of word in java using Apache POI

試著忘記壹切 提交于 2019-12-13 06:00:56
问题 I study on a web sharing project in jsf.In this project users can upload documents such as .doc,.pdf,.ppt,..etc . I want show this documents first pages as a thumbnail. After some googling around I found Apache POI.Can anybody has any suggestion for my problem? How can I return thumbnail image of word doc's first page? I try this code.This code just get first picture that word doc contains: POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("d:\\test.doc")); HWPFDocument doc = new

Jar Executable what am I doing wrong?

只谈情不闲聊 提交于 2019-12-13 05:23:44
问题 I am using the Eclipse IDE to program. After following a tutorial on Apache POI: https://www.youtube.com/watch?v=RsrF2Ku7ad4 I created an executable jar through eclipse and the following steps from the following link: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm From the menu bar's File menu, select Export. Expand the Java node and select Runnable JAR file. Click Next. In the Runnable JAR export wizard Runnable JAR File Specification page, I

With POI Word API, how to repeat a table heading on subsequent pages?

本秂侑毒 提交于 2019-12-13 05:18:45
问题 I am using Apache POI 3.12 for generating a Word document containing a XWPFTable. In the MS Word interface you can repeat a table heading on subsequent pages by checking a property on the table itself. How do you do the same using the XWPFTable API ? 回答1: In JWord that is set on Row level. There is method row.setHeader(true); Something similar should exist in the POI. 来源: https://stackoverflow.com/questions/34064758/with-poi-word-api-how-to-repeat-a-table-heading-on-subsequent-pages

How to resove the issue unable to resolve class XSSFWorkbook?

蓝咒 提交于 2019-12-13 05:18:02
问题 I am trying to read the xlsx file using the below code but getting unable to result class.. any help would be appreciated... org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script7.groovy: 8: unable to resolve class XSSFWorkbook @ line 8, column 11. srcBook = new XSSFWorkbook(new FileInputStream(new File("C:\\PerTableData\\TestData-Mix.xlsx"))) ^ org.codehaus.groovy.syntax.SyntaxException: unable import org.apache.poi.ss.usermodel.*; //import org.apache.poi.ss