apache-poi

Convert doc to pdf using Apache POI

有些话、适合烂在心里 提交于 2019-12-17 19:00:41
问题 I am trying to convert doc to pdf using Apache POI, but the resulting pdf document contains only text, it is not having any formating like images, tables alignment etc. How can I convert doc to pdf with having all formattings like tables, images, alignments? Here is my code: import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStream; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text

POI performance

浪子不回头ぞ 提交于 2019-12-17 18:18:08
问题 I am using POI in my J2EE web application to generate a workbook. However, i find that POI takes around 3 mins to create a workbook with 25K rows(with around 15 columns each). Is this a POI performance issue , or is it justified to take that much of time? Are there other APIs known for better performance ? 回答1: I would be very surprised to see POI take that much time to generate such a file. I just generated a sheet with 30000 rows x 10 cells in about 18s (no formatting, to be fair). The

How to copy a sheet between Excel workbooks in Java [closed]

↘锁芯ラ 提交于 2019-12-17 18:15:58
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . How can I copy a sheet between two different workbooks in Apache poi? The method is missing referring this thread. There is not such a solution. 回答1:

How to apply bold text style for an entire row using Apache POI?

寵の児 提交于 2019-12-17 18:08:10
问题 How to make an entire excel row cells bold text using Apache POI? E.g: Column headings should be in bold. Instead of applying style for each and every cell of heading row, how can I apply some style to an entire row? 回答1: This should work fine. Workbook wb = new XSSFWorkbook("myWorkbook.xlsx"); Row row=sheet.getRow(0); CellStyle style=null; XSSFFont defaultFont= wb.createFont(); defaultFont.setFontHeightInPoints((short)10); defaultFont.setFontName("Arial"); defaultFont.setColor(IndexedColors

Using Apache POI HSSF, how can I refresh all formula cells at once?

坚强是说给别人听的谎言 提交于 2019-12-17 17:43:10
问题 I am filling cells of an Excel file using Apache POI, and there are a lot of formula cells in the document. However, their values are not refreshed when I open the document in Excel. It's my understanding that I need to use a FormulaEvaluator to refresh formula cells. Is there a way, though, to update all formula cells at once? There are a lot of them, and while making an exhaustive list is not out of question, it's certainly not something I'm very willing to do. 回答1: Sure. Refreshing all the

returning decimal instead of string (POI jar)

牧云@^-^@ 提交于 2019-12-17 17:12:16
问题 I need to read xls or xlsx sheet. successfully I read the sheet, but it returning decimal value instead of string (eg: for 3 -- it is returning 3.0). I need to read the cell values as it is. so I need to return as string 回答1: POI is giving you the exact value that Excel has stored in the File. Generally, if you write a number in an Excel cell, Excel will store that as a number with formatting. POI provides support to do that formatting for you if you want it (most people don't - they want the

Using com.bea.xml.stream package on android

孤者浪人 提交于 2019-12-17 17:01:32
问题 For getting Apache POI to work on Android, I need to get Stack to work on Android. Following this question:Using JAXB with Google Android and @Sean Barbeau's answer. I successfully converted all the jar's to android compatible ones including the Apache POI library but it still gives me this run time error: 06-22 01:06:52.461 14865-14865/com.quizwiz.sharmakritya.poi E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.quizwiz.sharmakritya.poi, PID: 14865 edu.usf.cutr.javax.xml.stream

How to avoid java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.copy(Ljava/io/InputStream;Ljava/io/OutputStream;) in Apache POI

﹥>﹥吖頭↗ 提交于 2019-12-17 16:45:13
问题 I have a code for adding watermark to existing .doc file. The following is the code I have tried so far public static void main(String[] args) { try { XWPFDocument xDoc = new XWPFDocument(new FileInputStream("test.doc")); XWPFHeaderFooterPolicy xFooter = new XWPFHeaderFooterPolicy(xDoc); xFooter.createWatermark("My Watermark"); } catch(Exception e) { e.printStackTrace(); } } The following is what I got Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.copy

Why do I failed to read Excel 2007 using POI?

你。 提交于 2019-12-17 16:44:05
问题 When I try to initialize a Workbook object I always get this error: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF) But I followed the office sample to do this, following is my code: File inputFile = new File(inputFileName); InputStream is = new FileInputStream(inputFile); Workbook wb = new XSSFWorkbook(is); Exception occurs at

Get columns' names in Excel file using Apache POI

佐手、 提交于 2019-12-17 16:28:51
问题 How to get the column names in an Excel file using Apache POI, to make sure that the columns are ordered as expected. 回答1: Or this: cell.getSheet().getRow(0).getCell(currentcellIndex) .getRichStringCellValue().toString() Row indexes start from 0. 回答2: There is a convenience method for this: CellReference.convertNumToColString(cell.getColumnIndex()); To get the full name: private static String getCellName(Cell cell) { return CellReference.convertNumToColString(cell.getColumnIndex()) + (cell