apache-poi

XMLBeans Duplicate Class and Class Not Found Errors

▼魔方 西西 提交于 2019-12-11 03:23:29
问题 I have been trying for days to get the Apache POI API to work, but I keep running into errors with the xmlbeans2.6.0 jar . First, whenever I tried to run my app, it would crash saying that there was a duplicate class, so I did the usual method of extracting all the files and converting those files back into a jar; however, now I get that this error: java.lang.ClassNotFoundException: Didn't find class "org.apache.xmlbeans.XmlOptions" on path: DexPathList[[zip file "/data/app/arcane.com

couldn't get/set checkbox value in Word document (.doc) with Apache POI

谁说胖子不能爱 提交于 2019-12-11 03:18:02
问题 I'm trying to get/set checkbox value in Word document (.doc) with Apache POI. I looked HWPFDocument API at poi.apache.org , but haven't found anything suitable... Maybe somebody have a solution? Thank You! 回答1: Unfortunately, this is currently not supported by POI. What does work is to read out (not set) dropdown lists via CharacterRun.getDropDownListValues() and CharacterRun.getDropDownListDefaultItemIndex(). Technically those dropdown lists are closely related to checkboxes, though. So it

Apache POI: Replace paragraph text

穿精又带淫゛_ 提交于 2019-12-11 03:06:15
问题 I am using Apache POI to generate docx files from a template. There doesn't seem to be an obvious way to replace all text in a paragraph and the documentation is pretty scarce. Right now I am able to read a document by looping through its paragraphs, then looping through each paragraph's runs, then looping through each run's text... This works pretty well and I can replace the contents of a text in a run, but my template placeholders (example: <>) may be split into several runs, which makes

While Reading the data from Excel file with extension xlsx using apache poi it takes long time

跟風遠走 提交于 2019-12-11 02:58:02
问题 While reading the excel file with extension xlsx using apache poi it takes the long time for identifying the extension. Can you please help why it takes the long time? if (file.getExcelFile().getOriginalFilename().endsWith("xls")) { workbook = new HSSFWorkbook(file.getExcelFile().getInputStream()); } else if (file.getExcelFile().getOriginalFilename().endsWith("xlsx")) { workbook = new XSSFWorkbook(file.getExcelFile().getInputStream()); } else { throw new IllegalArgumentException("Received

Apache poi setformula doesn't work With SE

点点圈 提交于 2019-12-11 02:43:02
问题 I'm trying ti set a formula in a XSSFCell With POI. Cell.setFormula("SE(D87=0; ""; D80/D87)"); The error is: Name 'SE' is completely unknown in the current workbook. Why? 回答1: It looks like you are attempting to create an IF formula. I found this page about Excel formula translations into different languages, where I found that the English formula name IF translates to SE in a few languages. I don't believe that Apache POI supports formula names in names other than English. Try the English

Merging Cells Vertically and Inserting Data Into The Cell

谁说我不能喝 提交于 2019-12-11 02:28:06
问题 My question is I have 4 values. I need to represent them in a single cell. I need to merge the cells vertically (columns) and present the four values one below the other (top to bottom) having line feeds between in that merged cell. I am able to merge the cells vertically but unable to present the four values in a single cell. CellRangeAddress cellRangeAddress = new CellRangeAddress(2,5,5,5); sheet.addMergedRegion(cellRangeAddress); 回答1: The merged cell region orients them self on the first

Apache POI Excel getDateCellValue() wrong year

一笑奈何 提交于 2019-12-11 02:21:04
问题 I am using Apache POI to read several Excel files and convert them to an Oracle DB. My code looks roughly like this: wb = new HSSFWorkbook( new FileInputStream( FORECAST_HEADER_EXCEL_FILE ) ); Sheet sheet = wb.getSheetAt( 0 ); int rows = sheet.getPhysicalNumberOfRows(); // For each row... for ( int r = 0; r < rows; r++ ) { Row row = sheet.getRow( r ); ForecastLine forecastLine = new ForecastLine(); cell = row.getCell( EXCEL_COLUMN_BUCKET_START ); forecastLine.setBucketStart( cell == null ?

Is there any way to move horizontal scroll bar the sheet one column to the left using POI?

痴心易碎 提交于 2019-12-11 02:14:32
问题 I have written a program that reads Excel template sheet. In which the first column was hidden. Now, I have a code that un-hide the excel column programmatically (so Column start from A1). I'm using Apache POI 3.16 version. When I open a file, it should show me a column from A1 instead it shows me from B1 column. When I write below code for XLS, It working properly but didn't work for an XLSX format. sheet.showInPane(0, 0); I need to manually move the horizontal scroll bar to view my first

Read data from read only xlsm file using Java Apache POI

霸气de小男生 提交于 2019-12-11 01:56:59
问题 I'm trying to read data from a read only xlsm using java apache poi, but when I use XSSF workbook it doesn't seem to be able to access the file and HSSF workbooks only work for xls files. My code looks like this: try { FileInputStream file = new FileInputStream(new File("file.xlsm")); System.out.println("found file"); XSSFWorkbook workbook = new XSSFWorkbook(file); System.out.println("in workbook"); XSSFSheet sheet = workbook.getSheet("Shipments"); System.out.println("got sheet"); The code

How to get pictures and tables from .docx document using apache poi?

自古美人都是妖i 提交于 2019-12-11 01:49:01
问题 Dears, kindly i tried to extract whole document from .docx file to a text area in java, and What i only receive is text without images or tables, so any advice? Thanks in advance. My code is : try{ JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(null); XWPFDocument doc = new XWPFDocument(new FileInputStream(chooser.getSelectedFile())); XWPFWordExtractor extract = new XWPFWordExtractor(doc); content.setText(extract.getText()); content.setFont(new Font("Serif", Font.ITALIC, 16