apache-poi

Excel export in Android

假装没事ソ 提交于 2019-12-13 05:08:54
问题 I need to export excel from my android app. I use Apache-POI library and I get en exception when I run my app "NoClassDefFoundError". But the class is in "poi-ooxml-3.9-20121203.jar" and the jar is connected as external jar. I suppose that it is impossible to use that lib in android development. Any idea or library which can help me for these points: Create Excel file Read and add rows to it 回答1: I have been trying to use Apache POI for my app too and my conclusion was that it has

Apache POI image scale image

别来无恙 提交于 2019-12-13 04:54:53
问题 Hello I want insert image to word document. Below code inserts the image in its original size: private def writePhotosToDoc(model: WordReportModel, doc: XWPFDocument): Unit = { val paragraphIndex = detectVariable(Variables.PHOTO_APPLICATION, doc) if (!paragraphIndex.exists(_ == ("idx", -1))) { val taskParagraph = doc.getParagraphs.asScala( paragraphIndex("idx") ) taskParagraph.removeRun( paragraphIndex("irx") ) model.attachments.foreach{ case(key, value) => val p = doc.createParagraph() p

Java: Apache POI Excel Spreadsheet GUI View

荒凉一梦 提交于 2019-12-13 04:43:40
问题 My java application is using Apache POI to read/write Excel files. As far as I can see, Apache POI includes no support for an spread sheet view GUI. So my question is this: What is the best way to display an Excel-like spreadsheet view GUI within my application? I know I could parse in all of the spreadsheet info with POI and then output it in some custom java GUI components, but that would be really ghetto... especially with java's GUI (ew). Any advice is appreciated. Thanks 回答1: If you open

How to remove an image from an excel sheet (XSSF) in java

老子叫甜甜 提交于 2019-12-13 04:21:58
问题 I have now been trying for too long to remove an image from my XSSFSheet . I cannot find any information about this, but I would think that it has to be possible.. Is there any way to remove an image from my XSSFSheet ? Even the official (?) apache poi website does not mention anything besides creating and reading images I am now not far away from giving up and just copying everything except said image into a new sheet. Which is obviously not how this should be done. I don't think I would be

Changing value of cell in Excel via apache-poi

让人想犯罪 __ 提交于 2019-12-13 04:18:03
问题 I'm trying to change value of cell in .xls document. In .xls file i have got only 1 cell - A1 with abc value inside. My code: File fo = new File("D:\\TMP\\Zeszyt1.xls"); HSSFWorkbook a = new HSSFWorkbook(new FileInputStream(fo)); HSSFSheet my_sheet = a.getSheetAt(0); HSSFRow my_row = my_sheet.getRow(0); HSSFCell myCell; myCell = my_row.getCell(0); myCell.setCellValue("NEW VALUE"); How to commit this changes? When i open .xls file i still have got abc value inside A1. 回答1: You have to write to

getting no such method error in java

╄→尐↘猪︶ㄣ 提交于 2019-12-13 03:56:26
问题 I am getting the following error as shown below java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFSheet.addMergedRegion(Lorg/apache/poi/hssf/util/Region;)I at net.sf.jasperreports.engine.export.JRXlsExporter.createMergeRegion(JRXlsExporter.java:440) at net.sf.jasperreports.engine.export.JRXlsExporter.initCreateCell(JRXlsExporter.java:419) at net.sf.jasperreports.engine.export.JRXlsExporter.createTextCell(JRXlsExporter.java:381) at net.sf.jasperreports.engine.export.JRXlsExporter

Write items into excel cell

时间秒杀一切 提交于 2019-12-13 03:52:29
问题 I am absolute new to the Eclipse Java coding. I am trying to finish a project for managing the inventory. The part i am having trouble with is that, when I tried to write the items into the excel cell, I got errors saying that the array is out of bounds. PS: item and item.getPartname etc are all defined under another class file. Please help. thanks FileOutputStream os =new FileOutputStream("orderreceipt"); //Create a new workbook for writing data HSSFWorkbook wb2 = new HSSFWorkbook(); /

Add image into a word .docx document header using Apache POI XWPF

亡梦爱人 提交于 2019-12-13 03:51:13
问题 Can anyone please help me to add image into word document (.docx) header using Apache POI's XWPF component?. I tried very hard, but unable to find solution. 回答1: XWPFDocument doc = new XWPFDocument(); FileInputStream fis = new FileInputStream("/images/image.png"); XWPFParagraph par1 = doc.createParagraph(); XWPFRun runAppName = par1.createRun(); runAppName.addPicture(fis, Document.PICTURE_TYPE_PNG, "image.png", 257, 185); doc.write(new FileOutputStream(new File("/folder/document.docx"))); 来源:

Updating excel with values from rest assured json response using apache-poi

泄露秘密 提交于 2019-12-13 03:50:56
问题 I am a newbie with Rest Assured and seek help. I have written code to read values from an excel sheet and pass them as a path params in my Rest Assured tests. And this works as expected. However after I get the json response from the post request I make, I want to update the same excel with values from the response. The excel has columns called Train number, date of journey and various class codes as other columns like first class code, business class code, standard class code that should

Executing a formula in Excel via Apache-POI throws RuntimeException

痴心易碎 提交于 2019-12-13 03:47:30
问题 I am trying to learn Apache POI and how to execute formulas in Excel via Java. I have a sample code, which should execute the following formula IF(B1<5,IF(c1={"high mech","low mech","mid mech"},10,IF(c1="electronic",20,0)),IF(B1>=5,IF(c1={"electronic"},40,0),0)) Code: public class ExpressionExample { public static void main(String[] args) throws Exception { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Sample sheet"); Row row = sheet.createRow(0);