apache-poi

Apache POI : Excel Pivot Table - Row Label

青春壹個敷衍的年華 提交于 2020-01-05 11:19:05
问题 I have a requirement to create a excel sheet in JAVA as below : I am not able to create a row label with multiple columns side by side ( menus and submenus filter ). Instead of displaying the submenu in different column, its coming under the menu column. Below is the piece of code which i have written : XSSFSheet sheet = my_xlsx_workbook.getSheetAt(0); AreaReference a=new AreaReference("A1:G7"); CellReference b=new CellReference("I5"); XSSFPivotTable pivotTable = sheet.createPivotTable(a,b);

From Excel Embedded Object to Base64 String in XML

青春壹個敷衍的年華 提交于 2020-01-05 11:05:15
问题 I have an Excel sheet that allows users to click on specific cells and attach/embed files. These files are typically .pdf and .jpg format. I've read the Busy Developers guide on how to read embedded files using Apache POI, however I don't think I'm actually reading the correct file because when I go to save file locally or encode then decode for testing, the file says corrupt and will not open. Here is some code: for (PackagePart pPart : workbook.getAllEmbedds()) { InputStream inputStream =

Make an exact copy of a paragraph including all contents and properties?

强颜欢笑 提交于 2020-01-05 10:09:14
问题 I'm trying to do an exact copy of one paragraph into another (I'm copying a template over to a new document for word-replacement). I'm doing this for paragraphs within a table cell, but I don't believe that is significant. The following code nearly works: for (XWPFParagraph p : cell.getParagraphs()) { XWPFParagraph np = newCell.addParagraph(); np.getCTP().set(p.getCTP()); } The problem is, while np.getCTP().xmlText().equals(p.getCTP().xmlTest() is true, np.getText() is blank while p.getText()

Apache poi XSSF Creating Excel Files - Create returns empty file with format or file extension not valid?

拟墨画扇 提交于 2020-01-05 09:13:00
问题 The relevant part of the Controller class: @RequestMapping(value = "/DBCompare/download", method = RequestMethod.GET) public void handleDownloadDBCompareReportGet(HttpServletResponse response, Model model){ try{ reportService.downloadResultsDto(reportDto); } finally{ } } The ReportService in this case only fetches some information from the database, and calls newTableCompare() from the CreateTable class. The following class should create a new Excel table, workbook, ect. import java.io

Change colors of line chart Apache POI

狂风中的少年 提交于 2020-01-05 07:08:07
问题 I've generated a line chart using Apache POI. I need to change the default colors I got in the chart. Can I use RGB codes to define specific colors to each line? My code is as follows. Drawing drawing = sheet4.createDrawingPatriarch(); ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 17, 22); Chart chart = drawing.createChart(anchor); ChartLegend legend = chart.getOrCreateLegend(); legend.setPosition(LegendPosition.RIGHT); LineChartData data = chart.getChartDataFactory()

How to delete an entire row from excel using Java Apache POI?

守給你的承諾、 提交于 2020-01-05 05:54:51
问题 I want to delete an entire row from excel, I have tried removeRow : XSSFRow rerow = sheet1.getRow(1); sheet1.removeRow(rerow); and shiftRows : int rowIndex = 1; int lastIntext = sheet1.getLastRowNum(); sheet1.shiftRows(rowIndex+1, lastIntext, -1); But it is deleting only values in row not the entire row. 回答1: Even i faced the same problems but figured after a couple of researches and found There was a bug/or they might have changed the behavior in <version>4.0.0</version> and <version>4.0.1<

How to delete an entire row from excel using Java Apache POI?

[亡魂溺海] 提交于 2020-01-05 05:54:41
问题 I want to delete an entire row from excel, I have tried removeRow : XSSFRow rerow = sheet1.getRow(1); sheet1.removeRow(rerow); and shiftRows : int rowIndex = 1; int lastIntext = sheet1.getLastRowNum(); sheet1.shiftRows(rowIndex+1, lastIntext, -1); But it is deleting only values in row not the entire row. 回答1: Even i faced the same problems but figured after a couple of researches and found There was a bug/or they might have changed the behavior in <version>4.0.0</version> and <version>4.0.1<

shiftRows() apache POI 3.9. Sorting sheet

陌路散爱 提交于 2020-01-05 05:42:07
问题 I came here from this topic: Apache-POI sorting rows in excel Here is my code: public class WorkWithData { private int rowNum; private Sheet sheet; private Workbook workbook; protected WorkWithData(File userFile) throws Exception { this.workbook = getWorkbook(userFile); sheet = workbook.getSheetAt(0); rowNum = sheet.getLastRowNum(); } protected Workbook getWorkbook(File userFile) throws Exception { InputStream inputStream = new FileInputStream(userFile); return WorkbookFactory.create

Problem with processing word document java

安稳与你 提交于 2020-01-05 04:57:19
问题 i need to replace some fields in Word Document file in java.I am using Apache Poi library , i am using this code to replace words. for (XWPFParagraph p : doc.getParagraphs()) { List<XWPFRun> runs = p.getRuns(); if (runs != null) { for (XWPFRun r : runs) { String text = r.getText(0); if (text != null) { System.out.println(text); if (text.contains("[Title]")) { text = text.replace("[Title]", wordBody.getTitle());//your content r.setText(text, 0); }if(text.contains("[Ref_no]")){ text=text

java.lang.NoSuchFieldError: DEFAULT

天涯浪子 提交于 2020-01-05 04:12:30
问题 I am currently using vscode and apache poi, created a program to automatically create a .xlsx program and have A1 cell input a String called "Tester", and that error pops up. Codes in my program: package excel_reader; import java.io.FileOutputStream; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ExcelWriter { public static void main