poi-hssf

Adding border to a merged region in POI XSSF workbook

烂漫一生 提交于 2019-12-20 12:30:48
问题 I'm using apache poi 3.7 and I need to put border to a range of cells or merged region. how can I to apply border to a merged region when the sheet and workbook type is XSSF. In HSSF type I use RegionUtil-/HSSFRegionutil, but if use the first object (Regionutil) in XSSF type its doesn't works and puts a black background color to the range of cells. Regionutil ussually works with CellRangeAddress and i don't find information about this trouble. I don't know if the CellRangeAddres causes this.

apache poi: saving jtable to a file

落花浮王杯 提交于 2019-12-19 18:55:46
问题 I've recently started working with java and I'm facing some issues with the apache poi library when I need to create an excel file starting from a jTable. I've read many threads and come up with some code which just won't work (even if this is pretty easy stuff and there were many examples, which makes me look even more dumb) and I was hoping someone could help me out. So here are the questions: a) why does the for loop, which is supposed to write the excel file, not fill every cell? (the

How to let user download the data in database to an excel sheet file from web application in Java/Struts?

北战南征 提交于 2019-12-13 21:56:05
问题 I want to generate a report which includes an excel sheet which is generated from the data from the database . I am using Apache POI HSSF for creating the excel sheet file in the model. Now how to let the user download the file i have created ? 回答1: Just use a servlet. Feed response.getOutputStream() to POI HSSF to write the workbook to. Most important bit is the Content-Disposition response header. If you set it to attachment , then the browser will pop a Save As dialogue. response

Null Pointer Exception

浪尽此生 提交于 2019-12-13 08:59:22
问题 I am getting a null pointer exception, but I dont know why. I checked to see if the cell was null before I read it to a string. So, why is that string null? private void fillArray() { try { readBook = new HSSFWorkbook(readFile); } catch (IOException e) { System.out.println("If we know what we're doing, no one should ever see this line."); } if (readBook != null) {HSSFSheet infoSheet = readBook.getSheetAt(0); HSSFRow headingsRow = infoSheet.getRow(0); int i = 0; HSSFCell cell = headingsRow

Insert a checkbox in an Excel sheet using Apache POI

半腔热情 提交于 2019-12-11 16:36:26
问题 I want to pragmatically insert a number of checkbox in different cells. I want to keep a reference for each one in order to read them later on after the user check or uncheck. Can I do that in Java POI ? if not what is other alternatives to do it? thank you 回答1: You can create custom check box with macros with help of Microsoft visual basic+java , in java alone that facility is not available 来源: https://stackoverflow.com/questions/15243438/insert-a-checkbox-in-an-excel-sheet-using-apache-poi

POI Excel HSSFPicture Image and ALT TEXT

橙三吉。 提交于 2019-12-11 12:13:19
问题 I am using POI Excel HSSFPicture to create an image and add it to my excel file. I would like to add ALT TEXT to my image but I cannot find a way to add description to my image. Is there a way to add ALT TEXT to an image using POI for Excel? 回答1: Your requirement is to display alt text when the Image is not visible, right? So just an alternate try to use the Cell Comments to display the alt text. 来源: https://stackoverflow.com/questions/31147214/poi-excel-hssfpicture-image-and-alt-text

How to create cell with multiple styles in excel using HSSFSheet Apache POI?

拜拜、爱过 提交于 2019-12-07 08:48:59
问题 I am creating a script for export document as excel. How to have cell value like " Name: Mark DOB: 11-11-2014" by merging few cells? 回答1: What you need to do is create a RichTextString for your cell. That's the way of applying different formatting / styles to different parts of the same cell for display in Excel You'll want to review the POI "Working With Rich Text" example for more on how to use it, but broadly it'll be something like Cell cell = row.createCell(1); RichTextString rt = new

Getting error “Your InputStream was neither an OLE2 stream, nor an OOXML stream” when created file through apache POI

穿精又带淫゛_ 提交于 2019-12-05 23:59:26
I am trying to check if my excel file already exists. If it doesn't exists, I want to create a new one and if it exists I will delete it and create a new one. I wrote following program but I am getting error at line - workbook= WorkbookFactory.create(instream); The error is-> java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:89) at tryIng.main(tryIng.java:84) Here is a program -> try { String filePath= "C:/Users/pritik/Desktop/t1.xlsx"; File file = new File(filePath);

How to create cell with multiple styles in excel using HSSFSheet Apache POI?

荒凉一梦 提交于 2019-12-05 19:04:25
I am creating a script for export document as excel. How to have cell value like " Name: Mark DOB: 11-11-2014" by merging few cells? What you need to do is create a RichTextString for your cell. That's the way of applying different formatting / styles to different parts of the same cell for display in Excel You'll want to review the POI "Working With Rich Text" example for more on how to use it, but broadly it'll be something like Cell cell = row.createCell(1); RichTextString rt = new XSSFRichTextString("The quick brown fox"); Font font1 = wb.createFont(); font1.setBoldWeight(Font.BOLDWEIGHT