apache-poi

Java Swing Apache POI make Word Document read only

五迷三道 提交于 2021-02-19 23:15:56
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

老子叫甜甜 提交于 2021-02-19 23:10:57
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

二次信任 提交于 2021-02-19 23:08:36
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

旧城冷巷雨未停 提交于 2021-02-19 23:08:26
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Setting custom font color for XSSFWorkbook in Apache POI

回眸只為那壹抹淺笑 提交于 2021-02-18 21:01:43
问题 I'm having a little trouble with setting a custom font color for an XSSFWorkbook from Apache POI . When I do: yellow = workbook.createCellStyle(); Font whiteFont = workbook.createFont(); whiteFont.setColor(new XSSFColor(new Color(255, 255, 255)).getIndexed()); yellow.setFillForegroundColor(new XSSFColor(yellowRGB)); yellow.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND); yellow.setFont(whiteFont); The font stays black, I'm not sure what I'm doing wrong though. 回答1: You can do whiteFont

Setting custom font color for XSSFWorkbook in Apache POI

 ̄綄美尐妖づ 提交于 2021-02-18 20:59:40
问题 I'm having a little trouble with setting a custom font color for an XSSFWorkbook from Apache POI . When I do: yellow = workbook.createCellStyle(); Font whiteFont = workbook.createFont(); whiteFont.setColor(new XSSFColor(new Color(255, 255, 255)).getIndexed()); yellow.setFillForegroundColor(new XSSFColor(yellowRGB)); yellow.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND); yellow.setFont(whiteFont); The font stays black, I'm not sure what I'm doing wrong though. 回答1: You can do whiteFont

apache poi apply one style to different workbooks

戏子无情 提交于 2021-02-18 05:00:27
问题 I'm trying to apply one cell style to defferent woekbooks. It works well, when I apply it to first workbook, but when I'm trying to do this with second and next workbooks - no style is applied and the following exception is thrown. Exception in thread "Thread-3" java.lang.IllegalArgumentException: This Style does not belong to the supplied Workbook Stlyes Source. Are you trying to assign a style from one workbook to the cell of a differnt workbook? at org.apache.poi.xssf.usermodel

PREMATURE END OF FILE - XWPFDocument to PDFConverter

旧街凉风 提交于 2021-02-17 05:48:47
问题 Instead of appending the content of a document to CTBody Class, I am transfering all the data from a word document to an empty document using XWPFDocument class but I am getting an error as below. the error is pointed on XWPFDocument doc when I convert it to pdf fr.opensagres.poi.xwpf.converter.core.XWPFConverterException: org.apache.xmlbeans.XmlException: error: Premature end of file. FileInputStream fis = new FileInputStream("1.docx"); FileInputStream fis1 = new FileInputStream("2.docx");

XSLFGroupShape does not encompass its child shapes

故事扮演 提交于 2021-02-17 03:34:33
问题 I'm using Apache POI 3.16 (the latest version at the time of writing). In the following snippet, I create a XSLFGroupShape which I then use to create a bunch of child shapes: XSLFGroupShape group = slide.createGroup(); XSLFAutoShape cardRect = group.createAutoShape(); cardRect.setShapeType(ShapeType.RECT); cardRect.setAnchor(rect); XSLFPictureShape avatarShape = group.createPicture(avatar); // More shapes added to the group here... The problem is the following: in the generated PowerPoint

Apache POI bullet spacing

坚强是说给别人听的谎言 提交于 2021-02-17 02:46:32
问题 I am working on a project to generate a word document that has bullets. By default the bullets are followed by a large gap before the text. In Word, under List Indents Follow number with option, you can set this space to be a tab character, space character or none. By default in POI it is set to tab it appears. How can I change this to use space character? 回答1: I would highly recommend to use tab stop as this is the default in Word and correctly using this also leads to a proper presentation