apache-poi

Adding border to a merged region in POI XSSF workbook

烂漫一生 提交于 2019-12-20 12:30:48
问题 I'm using apache poi 3.7 and I need to put border to a range of cells or merged region. how can I to apply border to a merged region when the sheet and workbook type is XSSF. In HSSF type I use RegionUtil-/HSSFRegionutil, but if use the first object (Regionutil) in XSSF type its doesn't works and puts a black background color to the range of cells. Regionutil ussually works with CellRangeAddress and i don't find information about this trouble. I don't know if the CellRangeAddres causes this.

Reading and writing from xls and xlsx excel file in java using Apache POI

≯℡__Kan透↙ 提交于 2019-12-20 12:15:25
问题 I am writing a program which needs to read and write from excel files, irrespective of the format(xls or xlsx). I am aware of the Apache POI, but it seems it has different classes to handle xls file(HSSF) and xlsx(XSSF) files. Anyone aware of how I might achieve what I am trying to do here. (Ideas for using an API other than POI are also welcome). 回答1: It's very easy, just use the common SpreadSheet interfaces Your code would look something like: Workbook wb = WorkbookFactory.create(new File(

Updating existing Excel file in Java Apache POI

…衆ロ難τιáo~ 提交于 2019-12-20 10:11:07
问题 I'm trying to write a Java program that will run daily (using a task scheduler) and will append a column to an Excel spreadsheet every time it runs. The problem I am having is it merely re-writes the file, not appending to it. I am using Apache POI, here is the relevant code: public static void toExcel(List<String> results, List<Integer> notActive)throws IOException{ try { FileInputStream fIPS= new FileInputStream("test.xls"); //Read the spreadsheet that needs to be updated HSSFWorkbook wb;

Apache POI Performance

时光毁灭记忆、已成空白 提交于 2019-12-20 09:45:25
问题 I'm having performance problems with Apache POI. I've read the FAQ where it refers to a performance test. I've run this test with logging off and 4gb of heap and I can't get the tests to run faster than 22 seconds. This is the test I'm running: http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java The FAQ says that if I can't get this test to run in under 3 seconds with 50,000 rows and 50 columns that "the problem is with your environment

Getting Data from Excel

╄→гoц情女王★ 提交于 2019-12-20 07:35:26
问题 I need to Test an Affiliate Site , Scenario is , Click on Link , New Window get Open , Get Key from that new open source code and compare with Actual Key with Expected Key , I had done it , but problem is there is too many link to be capture , so what i suggested to put all link xpath , Expected Value , Actual value received from page source to an Excel File and use Apache POI to run my test cases . Here is my code which i am working on : public void test() throws Exception { String home_logo

Apache POI XSLF Adding movie to the slide

非 Y 不嫁゛ 提交于 2019-12-20 07:31:46
问题 I am using the Apache POI library to create powerpoint slides with Java. Our client is interested in embedded text, images and videos. No fancy stuff like charts etc. is needed for now. I understand that XSLF is still under development and not yet a mature product. I have achieved my target using Apache POI HSLF model but the only thing it is missing is that videos which are embedded doesn't show up any playback controls. After little researching I found that it is the pptx and ppt file

How to apply cell background color using HSSF using Java code

会有一股神秘感。 提交于 2019-12-20 07:27:00
问题 I'm trying to format the cell background color based on the Testcase Execution status like if the test case got passed then the cell background should become Green and text color should be White . Similarly for Failed test cases cell background color : Red and Text color : White For that I tried the following script. Background: HSSFCellStyle style = wBook.createCellStyle() style.setFillBackgroundColor(IndexedColors.GREEN.getIndex()) Foreground: HSSFFont font = wBook.createFont() font

Reading .docx file in java

我怕爱的太早我们不能终老 提交于 2019-12-20 06:46:20
问题 I am trying to read one file in java, following is the code : public void readFile(String fileName){ try { BufferedReader reader= new BufferedReader(new FileReader(fileName)); String line=null; while((line=reader.readLine()) != null ){ System.out.println(line); } }catch (Exception ex){} } It is working fine in case of txt file. However in case of docx file, it is printing weird characters. How can i read .docx file in Java. 回答1: import java.io.File; import java.io.FileInputStream; import java

Excel Cell value with Number format and Category as Currency is not retrieved through Apache POI 3.6

不羁岁月 提交于 2019-12-20 05:55:33
问题 Hi Iam parsing a cell in excel with a particluar format for which the Data format string is coming as "$"#,##0 I want to fetch value within that cell but not able to do so, can someone help? Currently with this code i am getting value as blank , but in excel the value is for e.g. $40. for (Row row : sheet) { Cell dataCell = row.getCell(colIndex); if(dataCell!=null ) { if( row.getRowNum()==5) { System.out.println("Cell Value is::"+dataCell.toString()); } } } 回答1: You seem to want the string to

How do i write/paste a captured image to a doc file?

 ̄綄美尐妖づ 提交于 2019-12-20 05:53:41
问题 I have a scenario where i need to capture image and write them to a word file one after the other. I have written the below code but doesn't seem to be working. Please help Robot robot; try { robot = new Robot(); BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(screenShot, "JPG", new File("C:\\xxx\\Gaurav\\NEW1.JPG")); InputStream is = new