apache-poi

Apache Poi performance issue with WorkbookFactory.create()

喜你入骨 提交于 2019-12-11 20:04:02
问题 I am trying to retrieve named ranges from excel file using the apache poi plugin. The code snippet is as given below. I see that call WorkbookFactory.create(excelFile); is taking a long time - about 3 seconds. Is there a faster way of getting all the named ranges associated with excel sheet? File excelFile = new File(filePath); Workbook workbook = WorkbookFactory.create(excelFile); int n = workbook.getNumberOfNames(); for (int i = 0; i < n; i++) { Name nameObject = workbook.getNameAt(i);

parse json structure from excel sheet into java

大城市里の小女人 提交于 2019-12-11 19:58:30
问题 i have a data in excel sheet that i need to read in java, i am able to read normal content but not able to read the json structure that i have stored. how can i parse json from excel to java? public class JavaApplication1 { public static void main(String[] args) { try { for (int i=0;i<5;i++) { FileInputStream fileInputStream = new FileInputStream("C://users/user/Desktop/C.xls"); HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream); HSSFSheet worksheet = workbook.getSheet("POI Worksheet")

How to collapse all fields in pivot table from java?

回眸只為那壹抹淺笑 提交于 2019-12-11 19:26:22
问题 I am creating a pivot table using apache poi in JAVA and it generates a pivot table like below with all rows expanded by default How do I generate Pivote table will all rows collapsed like below from java Code. Thank you in advance. Code used for generating pivot table AreaReference a=new AreaReference("A1:G5667", null); CellReference b=new CellReference("A1"); XSSFSheet pivot_sheet=workbook.createSheet("Pivot_table"); XSSFPivotTable pivotTable = pivot_sheet.createPivotTable(a,b,spreadsheet);

How to hide particular column in Pivot Table using Apache POI (Java)

我的未来我决定 提交于 2019-12-11 18:47:34
问题 while hiding column in pivot table. text above pivot table also getting removedI want to hide one column in pivot table. If I remove that column then the functionality should not get effected. How can I achieve that functionality by removing or hiding that column in pivot table public class Createxlsx { public static void main(String[] args) throws FileNotFoundException, IOException, InvalidFormatException { createPivotTable(); } private static void createPivotTable() throws IOException,

List All defined names from Excel Using Apache POI

喜夏-厌秋 提交于 2019-12-11 18:29:23
问题 How can i get the list of all the defined names/ range names in excel using Apache POI? EDITED: Thanks to @Axel Richter, Here is the code List definedNames = new ArrayList(); definedNames = workbook.getAllNames(); Iterator<List> definedNameIterator = definedNames.iterator(); while (definedNameIterator.hasNext()) { Name name = (Name) definedNameIterator.next(); System.out.println(name.getNameName()); System.out.println(name.getRefersToFormula()); System.out.println(); } 回答1: List definedNames

How to skip the rows in a xlsm file using apache event user model

妖精的绣舞 提交于 2019-12-11 18:16:41
问题 I am working on a large excel file and i am taking reference from apache poi event user model(The Halloween Document).http://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api. The xlsm file looks like this so my purpose is to skip the cell i have marked ,i.e starting from 1 to 6 row wise i wan to skip.I am using poi workbook then i would have done like currentRow.getRowNum() This way i can get the row numbers in that excel file. But how this api handles each row i don't know .So from the

Apache POI - Extracting all different values in a column

我的梦境 提交于 2019-12-11 18:12:59
问题 I have an excel file that look like this - Ticket # Status Person 1. Open John 2. Working Mark 3. Pending Betty 4. Working Mark 5. Open Mark 6. Open John 7. Pending Betty 8. Working John 9. Working Mark 10. Pending Betty I want to extract following information Names of all the different people (in column 3, in this case - John, Mark and Betty). How many tickets for a person are a.Open b.Working c.Pending. (Eg - For John, 2 tickets are open, 1 is working and 0 is pending). I am using Apache

The easiest way to implement a barchart with 2 columns using apache poi and ooxml-schemas

纵饮孤独 提交于 2019-12-11 17:50:01
问题 I'm trying to create n bar chart of 2 columns in a xlsx file like below. But It's so confuse to me , to understand how the class inside the org.openxmlformats.schemas.drawingml.x2006.chart works. I've already tryied but the generate file does not get the chart that I have drawed. I have this code: Drawing drawing = planilha.createDrawingPatriarch(); ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 5, 15); Chart chart = drawing.createChart(anchor); CTChart ctChart = ((XSSFChart

Anomalies adding PNG in xlsx - Apache POI 3.9

百般思念 提交于 2019-12-11 17:44:50
问题 I'm able to add pngs to my xlsx but with a few anomalies: On the last row (only), the image is overlaid on the previous row's image: I suspect the anchoring: int pictureIndex = report.addPicture(curve, XSSFWorkbook.PICTURE_TYPE_PNG); anchor.setCol1(7); **anchor.setRow1(rowNumber-1);** anchor.setCol2(8); anchor.setRow2(rowNumber); drawing.createPicture(anchor, pictureIndex); But if I follow the examples I've seen, anchor.setRow1(rowNumber) then my images don't show at all. Last, is there a way

how to generate stackedBar chart using apache poi 4.0 XDDFChartData, XDDFBarChartData ; in excel sheet using java, i dont want to use jfree

本小妞迷上赌 提交于 2019-12-11 17:18:44
问题 I need a sample code in Java, currently I am able to draw line and pie charts charts after reading values from sheet, and I also want to generate a StackedBar chart. I added a snipplet of code for pie chart which I have attempted which is for .ppt format. I want the same in excel for stackedBar chart in java. String[] categories = listCategories.toArray(new String[listCategories.size()]); Double[] values = listValues.toArray(new Double[listValues.size()]); final int numOfPoints = categories