apache-poi

Replace text in text box of docx by using Apache POI

一笑奈何 提交于 2019-12-06 10:36:40
I am using Apache POI to replace words of docx. For a normal paragraph, I success to use XWPFParagraph and XWPFRun to replace the words. Then I tried to replace words in text box. I referenced this https://stackoverflow.com/a/25877256 to get text in text box. I success to print the text in console. However, I failed to replace words in text box. Here are some of my codes: for (XWPFParagraph paragraph : doc.getParagraphs()) { XmlObject[] textBoxObjects = paragraph.getCTP().selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' declare namespace wps='http:

Reading property sets from Office 2007+ documents with java poi

核能气质少年 提交于 2019-12-06 10:11:01
问题 I have tried to read property sets from Office 2007+ documents (docx, xlsx). Found the amazing solution on http://poi.apache.org/hpsf/how-to.html. There is an example for Office 2003 and early format (doc, xls, without "x"). public class ReadSummaryInformation { public static void main(final String[] args) throws IOException { final String filename = "C://file.docx"; POIFSReader r = new POIFSReader(); r.registerListener(new MyPOIFSReaderListener(), "\005SummaryInformation"); r.read(new

I want to arrange entire cells in specific column, instead of individual cells

大兔子大兔子 提交于 2019-12-06 09:39:07
问题 I used POI and tried to arrange one entire column. But only the way I found is arrange individual cell. Although I found sheet.setDefaultColumnStyle() and tried to use this function, it doesn't work at all. could you let me know the way of using setDefaultColumnStyle() or another way. below code is my code to arrange individual cell. xlsxFile = new File("data.xlsx"); wb = new XSSFWorkbook(); cellStyle = wb.createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_CENTER); cellStyle

how change text direction(not paragraph alignment) in document in apache poi word?(XWPF)

穿精又带淫゛_ 提交于 2019-12-06 09:23:08
I'm trying to use Apache poi word 3.8 to create word document in persian/arabic language. My question is: how change text direction in document? ( it means changing text direction not changing just paragraph text alignment) In MS Word we could use Right-to-left text direction to change text direction and Align Right to set alignment. What’s equivalent of the first one in poi set property? This is bidirectional text direction support (bidi) and is not yet implemented in apache poi per default. But the underlying object org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrBase supports

How to insert a table in ms excel using apache java poi

六眼飞鱼酱① 提交于 2019-12-06 09:07:52
I am trying to insert a table in Excel using Java Apache Poi. But when I am opening the xlsx file it is throwing the following error and I could not solve it: Removed Part: /xl/tables/table1.xml part with XML error. (Table) Load error. Line 2 repaired records: table from /xl/tables/table1.xml part (table) My code is the following: import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFTable; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org

How to create XSSFShape with no border outline of the shape?

强颜欢笑 提交于 2019-12-06 08:58:22
In Apache POI 3.9 for HSSFShape class there is a constant 'HSSFShape.LINESTYLE_NONE' and if I apply it using shape.setLineStyle(HSSFShape.LINESTYLE_NONE) then I can create a shape with no border. But in XSSFShape I guess similar constant 'XSSFShape.LINESTYLE_NONE' or something like that is missing. Please help with some another way by which I can create a XSSFShape with no border outline.. 来源: https://stackoverflow.com/questions/21396330/how-to-create-xssfshape-with-no-border-outline-of-the-shape

Understanding ZipSecureFile.setMinInflateRatio(double ratio)

寵の児 提交于 2019-12-06 08:18:58
问题 I am using this function call, because when I read a trusted file, It results in zipbomb error. ZipSecureFile.setMinInflateRatio(double ratio) FileInputStream file = new FileInputStream("/file/path/report.xlsx"); ZipSecureFile.setMinInflateRatio(-1.0d); XSSFWorkbook wb = new XSSFWorkbook(file); I am trying to understand how it works? The only source I could find is https://poi.apache.org/apidocs/org/apache/poi/openxml4j/util/ZipSecureFile.html But, couldn't get a clear picture as I am new to

Write data into Excel sheet java

爷,独闯天下 提交于 2019-12-06 08:02:10
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 Exception { //passing finalList here try { for (int j = 0; j < l1.size(); j++) { Row row = firstSheet

Which is better open source for Excel file parsing in Java?

元气小坏坏 提交于 2019-12-06 07:48:43
问题 Which is better API for excel parsing in Java Apache POI or JExcel API? In terms of speed, memory utilization and code stability. 回答1: Personally I would recommend POI over JExcel. The reasons I chose POI over JExcelAPI are: POI supports both old and new MS Excel sheet formats It has a cleaner API (imho) As far as I can see it does not suffer from the irritating Date\Time issues that JexcelApi has (Date display). I have had the opportunity to use both. POI, in my opinion, has a really well

PPT to PNG conversion with Apache POI

随声附和 提交于 2019-12-06 07:37:50
By following the example provided at http://poi.apache.org/slideshow/how-to-shapes.html i got the conversion to work. FileInputStream is = new FileInputStream("slideshow.ppt"); SlideShow ppt = new SlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); Slide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++){ BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); graphics.setPaint(Color.white); graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height)); slide[i].draw