apache-poi

Save Excel document Apache POI

為{幸葍}努か 提交于 2019-12-08 19:47:28
问题 I need to create informs from an excel document, I'm using Java and Apache POI. Here is my code: //Get path with JFileChooser public static String LeeRuta(){ JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.showDialog(chooser, "Seleccionar"); File f =chooser.getSelectedFile(); File camino = f.getAbsoluteFile(); String ruta = camino.getAbsolutePath(); return ruta; } //main public static void main(String args[]) { String ruta

How to change the specific text color in a same cell of excel sheet using apache poi?

陌路散爱 提交于 2019-12-08 19:18:51
问题 Does anyone know how to change the color of the particular text of a cell in excel. I am using apache poi and I could find out to change the text color of entire cell. But I want only a particular text. Eg: Cell A1 has Hello World I want "Hello" to be in blue and "World" to be in green. How do I do this? 回答1: The key is using the HSSFRichTextString object to set the value of the cell. This object has an applyFont method which accepts a startingIndex, endingIndex and a Font. Thus, you can

what give java.lang.NoClassDefFoundError?

浪子不回头ぞ 提交于 2019-12-08 17:47:18
问题 I want to read excel file but give Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject at ExcelReader.main(ExcelReader.java:32) Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown

How to format Excel Cell as Date in Apache POI as with the Format Painter operation in Excel

喜你入骨 提交于 2019-12-08 15:44:51
I am pretty new to Apache POI, I wonder how to do that Format Painter operation to format a cell into Date format, each time when I try to copy the date format of cell, in POI, it can only give me Numeric, I wonder how can I keep the date format? // Get source cell type and style CellType type_from = cell_from.getCellTypeEnum(); CellStyle style_from = cell_from.getCellStyle(); // Get source cell data format short df = style_from.getDataFormat(); // Change dest cell cell type, set format on it cell_to.setCellType(type_from); CellStyle style_to = cell_to.getCellStyle(); style_to.setDataFormat(df

java.lang.OutOfMemoryError: GC overhead limit exceeded when loading an xlsx file

匆匆过客 提交于 2019-12-08 15:26:35
I understand what the error means, that my program is consuming too much memory and for a long period of the time it is not recovering. My program is just reading 6,2Mb xlsx file when the memory issue occures. When I try to monitor the program, it very quickly reaches 1,2Gb in memory consumption and then it crashes. How can it reach 1,2Gb when reading 6,2Mb file? Is there a way to open the file in chunks? So that it doesn't have to be loaded to the memory? Or any other solution? Exactly this part causes it. But since it is a library, shouldn't it be handled somehow smartly? It is only 200 000

excel can not open the downloaded file through jsp

瘦欲@ 提交于 2019-12-08 15:05:15
问题 this is the code for download excel file on browser but when i open it excel throw a error "Excel can not open the file 'Location.xlsx' because the file format or file extension is not valid. verify that the file has not been corrupted and that the file extension matches the format of the file" but when i simply create this file its opening only this error is coming when i perform download operation and i am using poi jar for excel file creation...??? <html> <body> <% LocationDownload

org.apache.poi.xwpf.converter.xhtml.XHTMLConverter not generating images

我的梦境 提交于 2019-12-08 13:20:39
问题 I am using org.apache.poi.xwpf.converter.xhtml.XHTMLConverter class to convert docx to html. Below is my groovy code public Map convert(String wordDocPath, String htmlPath, Map conversionParams) { log.info("Converting word file "+wordDocPath) try { ... String notificationWorkingFolder = "C:\tomcats\Notification\store\Notification1234" FileInputStream fis = new FileInputStream(wordDocPath); XWPFDocument document = new XWPFDocument(fis); XHTMLOptions options = XHTMLOptions.create().URIResolver

Apache POI Charts - Title formatting

ε祈祈猫儿з 提交于 2019-12-08 12:35:43
问题 I created a line chart and when I add the title to my chart it overlaps my data. How do I add the title above my chart? Also how can I adjust the font/style of the title text? I want to make the text a little smaller. Drawing drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15); Chart chart = drawing.createChart(anchor); chart.setTitleText("This is my title"); // Use a category axis for the bottom axis. ChartAxis bottomAxis = chart

Can I get access to Lotus Notes embedded files without actually extracting them?

蓝咒 提交于 2019-12-08 11:42:30
问题 I'm working on a way of programatically accessing a Lotus Notes database to gather information on embedded attachments of records over a given period. My goal is to find records over a given period, then use Apache-POI to get metadata about document size, character count, etc. The POI part works fine, and so far, I've been able to access the Lotus Notes records thanks to this help: lotus notes search by date with Java api and this answer also shows me how to download/copy the attachments: How

Impossible to delete first row of Excel sheet

我只是一个虾纸丫 提交于 2019-12-08 11:40:42
问题 I want to delete completly the first row of my Excel sheet. However, everytime I launch my code, it erased totaly my sheet and every row becomes blank. Thank you in advance for your help. I know this question has already been processed many times, but none of the solution proposed worked on my case. There is something wrong for sure. String exportPath = "C:\\Users\\User\\Downloads\\export.xlsx"; FileInputStream inputStream = new FileInputStream(new File(exportPath)); Workbook export =