apache-poi

How to create hyperlink to a filter on other sheet using Apache poi in Java?

*爱你&永不变心* 提交于 2019-12-08 04:28:15
问题 I want to create a hyperlink from a field 'Name' on Sheet1 (Summary) to the AutoFilter on column 'Name' on Sheet2 (Details), in order to display the details of that particular name only on the Sheet2. I have imported : import org.apache.poi.ss.usermodel.Hyperlink; import org.apache.poi.ss.usermodel.CreationHelper; Hyperlink to filter on other sheet. I have done this using VB macro, but want to implement this using Java POI. 回答1: I had troubles with Hyperlinks some time ago, and the quickest

How to find out what makes poi corrupt a xlsx / xlsm file

末鹿安然 提交于 2019-12-08 04:10:26
I have the issue that Apache POI "corrupted" a xlsm / xlsx file by just reading and writing it (e.g. with the following code) public class Snippet { public static void main(String[] args) throws Exception { String str1 = "c:/tmp/spreadsheet.xlsm"; String str2 = "c:/tmp/spreadsheet_poi.xlsm"; // open file XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(new File(str1))); // save file FileOutputStream out = new FileOutputStream(str2); wb.write(out); wb.close(); out.close(); } } Once you open the spreadsheet_poi.xlsm in Excel you'll get an error like the following "We found a problem with

Edit Microsoft-office .doc file in java using Apache POI

风格不统一 提交于 2019-12-08 03:43:26
问题 I'm writing java code to achieve the followings. 1.Read given Microsoft-office document(.doc) file. 2.Search for given string in the file. 3.Delete the given String located in any place. 4.Insert or replace any given string at specified position. 5.Write and save the updated file content into new .doc file. I have written a code to read, search, insert or replace, delete and save the file and it's working good, but i couldn't able to preserve the text format(such as font color, font size,

Error in for loop with while reading excel file in hashmap

故事扮演 提交于 2019-12-08 03:17:29
问题 I am trying to access excel file in hashmap, but i=5 colNum getting as 8, so output is not getting as expected. Below is the code Reading this excel file with hashmap , once questionType matched i want to store only respective label and value then pass to respective class public class HashMapObjectTest { static HSSFSheet sheet; static HSSFRow row; private static MissingCellPolicy xRow; static DataFormatter df = new DataFormatter(); @Test public void getMapData() throws Exception { File src

How to get the whole row for a if specific column has a certain text with POI

我只是一个虾纸丫 提交于 2019-12-08 03:08:17
问题 I need to filter my excel spreadsheet for the word "GHH" anywhere in the text of a cell in a specific column. I have managed to do this by I then need to have returned the whole row that this text is found in. This I can't do as there doesnt seem to be a way of using the getRowIndex method to then display the whole row. Here is my code: public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream(new File("myfile.xls")); HSSFWorkbook workBook = new

How to copy a row from existing excel sheet to a new excel sheet using Apache POI?

徘徊边缘 提交于 2019-12-08 03:02:17
问题 I want to compare two excel sheets and find if any row differs, if it does I want to copy that single row which differs from that excel to a new row in a new excel. Below is a code snippet I took from the net and tried but the problem if I copy the 10th row of the existing excel(for example) to the first row of new excel, 1st row is properly copied in new excel but all the remaining rows from first excel are also copied to the new one. I think the problem is with the way I write to new excel

Apache POI jar has no hwpf package

大憨熊 提交于 2019-12-08 02:53:58
问题 I have downloaded the poi api jar files from this link's first mirror link,which is suggested. After downloaded I saw that org.apache.poi.hwpf package is not present there. Actually my work is completely depends on that API. So can anybody please tell me the proper link to download hwpf API . Actually my work is to read a MS Word file with some text as well as some table and then edit the values of the table rows. If any other API is also suitable for this kind of work, you please suggest me

Apache poi - print layout, more than one print area in the same sheet

纵然是瞬间 提交于 2019-12-08 02:47:23
问题 I'm trying to develop a complex report, and I need to set up the print areas for the excel file. I must divide the xls file in 3 part, but if I do setPrintArea(..) the new area subscribe the old and the result is that I have in the print preview only the last page. How can I set more than one print area? This is the code: protected void createCustomerSheet(String label) { createSheet(label); getCurrentSheet().getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE); getCurrentSheet()

Write data into Excel sheet java

非 Y 不嫁゛ 提交于 2019-12-08 02:20:27
问题 I have 3 lists namely list1, list2 and list3. And I want to display these lists in an excel sheet as 3 columns. For example the values in list 1 should be displayed in the first column of Excel sheet. I am adding all the 3 lists to a final list as below and able to display them as separate rows and no idea how can i display as columns. I am using apachepoi. List<List> finalList = new ArrayList<List>(); finalList .add(list1); finalList .add(list2); WritingToExcelFile(List<List> l1) throws

java POI XSSF FormulaEvaluator

我与影子孤独终老i 提交于 2019-12-08 01:52:54
问题 I am having a problem when i save my new excel file. I want it that when it gets saved the formula calculates itself but at the moment it is just returning a string in the excel file. The formula is correct. I don't know exactly to get the FormulaEvaluator to work. Here is where I enter my formula that returns a string: dataRow1.createCell((short)5).setCellValue("=VLOOKUP(A"+rowCountVlookup+",'C:\\Users\\Admin\\Documents\\JCreator LE\\MyProjects\\WordCount\\classes\\[Pricing.xlsx]Sheet1'!$B$3