apache-poi

Apache POI setPrintArea to A4 page size

て烟熏妆下的殇ゞ 提交于 2020-01-14 10:33:17
问题 I'm working with the Apache POI API to generate .xls files, and I want to set the printArea of my file. I know there is a funcion called setPrintArea() but this one receive as parameters start and end row and column of my print area. I want to know, if there is a way to set my print area for each sheet with the size of an A4 paper (210mmx290mm) Thanks. 回答1: For each Sheet in the workbook, get its PrintSetup object and call setPaperSize on it, passing the appropriate PrintSetup constant: A4

java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbook

自闭症网瘾萝莉.ら 提交于 2020-01-14 07:41:10
问题 when i tried to create a workbook in normal java class it is creating but when i tried to run the same on servlet it is throwing exceptions Normal java class import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class Sampleclass { public static void main(String[] args) { FileInputStream file; try { file = new FileInputStream

Write large text file data into excel

北城以北 提交于 2020-01-13 09:26:31
问题 I am reading a text file separated with some delimiters. Example of my text file content Avc def efg jksjd 1 2 3 5 3 4 6 0 line by line and holding it in memory using hashmap having line numbers as key of integer type and each line of text file as List object Consider, my map would store information like this Integer List 1 [Avc def efg jksjd] I am using Apache POI to write into excel. When writing into excel using Apache POI, I am following this approach, here is my code snippet HSSFWorkbook

How to parse UTF-8 characters in Excel files using POI

扶醉桌前 提交于 2020-01-13 09:16:33
问题 I have been using POI to parse XLS and XLSX files successfully. However, I am unable to correctly extract special characters, such as UTF-8 encoded characters like Chinese or Japanese, from an Excel spreadsheet. I have figured out how to extract data from a UTF-8 encoded csv or tab delimited file, but no luck with the Excel file. Can anyone help? ( Edit: Code snippet from comments ) HSSFSheet sheet = workbook.getSheet(worksheet); HSSFEvaluationWorkbook ewb = HSSFEvaluationWorkbook.create

.xls convert to xlsx using java and POI APACHE

倖福魔咒の 提交于 2020-01-12 09:39:04
问题 I'm trying to use POI.APACHE to edit excel files in java. I have to convert a .xls to .xlsx because I need to send the file to sharepoint. Thats why it just can't be renamed with a different extension. How would I go about this? I couldn't find any examples on their site. Thanks 回答1: import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io

Updating an MSWord document with Apache POI

て烟熏妆下的殇ゞ 提交于 2020-01-12 08:29:35
问题 I'm trying to update a Microsoft Word document using Apache POI. The msword document is a template that contains a number of placeholders in the form "${place.holder}" and all I need to do is to replace the holders with specific values. What I've got so far is private void start() throws FileNotFoundException, IOException { POIFSFileSystem fsfilesystem = null; HWPFDocument hwpfdoc = null; InputStream resourceAsStream = getClass().getResourceAsStream("/path/to/document/templates/RMA FORM.doc")

Auto wrap in apache POI (Excel)

為{幸葍}努か 提交于 2020-01-12 04:55:26
问题 I have a java program which takes header and data as the input and produces an excel file. However, sometimes when the header values are long and the number of columns are more, my excel sheet tends to be unnecessarily wide. Because of the headers, I will have to scroll down to right to see the content of the tail end columns. Is there a way I can resolve this such that if the content in the cell is bigger then say value x, then auto wrap occurrs and automatically the row height gets adjusted

Workbook takes long time to generate excel file

元气小坏坏 提交于 2020-01-11 13:24:52
问题 I'm trying to generate excel file with 200k records. But it is taking almost 2 hours to generate the file. Here is my code of generating excel file. Workbook workbook=null; csvFileName = userId+"_Records_"+new SimpleDateFormat("yyyyMMddHHmmss") .format(new Date())+".xls"; path = ReadPropertyFile.getProperties("download.reports.path"); misService.insertXLSRecord(ackNo,"-",null, VspCommonConstants.getIpFromRequest(request), new Date(), userId,"N",userReportRoleId); workbook = getWorkbook(path

How to add a table to header or footer?

半城伤御伤魂 提交于 2020-01-11 11:28:29
问题 I'm having serious trouble adding a new, simple XWPFTable to an XWPFHeader (or Footer). Unfortunately there seems to be only one guy having the same problem (https://bz.apache.org/bugzilla/show_bug.cgi?id=57366#c0). Does anyone has an approach to achieve this?? XWPFDocument docx = (XWPFDocument) dockingObject; CTSectPr sectPr = docx.getDocument().getBody().addNewSectPr(); XWPFHeaderFooterPolicy policy = new WPFHeaderFooterPolicy(docx, sectPr); XWPFHeader header = policy.createHeader

How to print a Workbook file made using Apache Poi and java?

狂风中的少年 提交于 2020-01-11 11:25:49
问题 I create one page workbook files in eclipse and need to open the print dialog box and print these files off. I understand how to open the print dialog box and everything, i just can't find how to tell the system that it is the workbook file "wb" that is what i'm wanting to print. So opening the dialog just doesn't work unless it knows what i'm trying to print with it. Could someone at least send me in the right direction Without telling me to read the java print dialog tutorials. I've read