apache-poi

Copy Excel Sheet using Apache POI

China☆狼群 提交于 2019-12-09 09:11:58
问题 How to copy one entire Excel sheet into another Excel sheet of the same workbook, using Java SE and Apache POI? 回答1: You'll probably want the cloneSheet(sheetNumber) method on the Workbook. See the JavaDocs for details 回答2: Did you check the API? to copy a sheet into the same workbook , use HSSFWorkbook.clonesheet(int sheetIndex) Ivan's comment has linked the question for copying across workbooks. 回答3: Yes , this can be...Here my code. XSSFWorkbook workbook = new XSSFWorkbook(file); int

How to check a cell text is strikethrough or not in .xlsx file using apache poi

纵饮孤独 提交于 2019-12-09 07:13:28
问题 I need to check the text format of a cell in .xlsx file (Microsoft Excel file) is strike through or not using Apache POI libraries. Look following Image Please Check this image ! I need to check whether B3 Cell text is strike through or not. 回答1: Finally I found a way to do this, code as follow //Using workbook XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("abc.xlsx"))); //Getting first sheet XSSFSheet sheet = workbook.getSheetAt(0); //Checking A1 cell that

POI XSSF / XLSX hashing indeterminism with MessageDigest SHA-256

◇◆丶佛笑我妖孽 提交于 2019-12-09 07:03:31
问题 There seems to be a problem with getting deterministic hash values for the POI XLSX format, with MessageDigest SHA-256 implementation, even for empty ByteArray streams. This happens randomly, after several hundreds or even only thousands of iterations. The relevant code snippets used to reproduce the problem: // TestNG FileTest: @Test(enabled = true) // indeterminism at random iterations, such as 400 or 1290 public void emptyXLSXTest() throws IOException, NoSuchAlgorithmException { final

Is there any way to create a Pivot Table in Excel using Apache POI?

别等时光非礼了梦想. 提交于 2019-12-09 05:28:00
问题 I am currently working on the automation of Excel, and add such I have made a good use of the Apache POI library. As I have so much data stored in my excel workbook in various columns, that I'm trying to create a pivot table. Is there any way to create Pivot tables using POI ? My requirement is that I need to create the pivot table in a new excel workbook or in the same workbook where I store my data. 回答1: The 'Quick Guide' is quite out of date. The change log refers to this bugzilla issue as

Streaming a POI workbook to the servlet output stream

只愿长相守 提交于 2019-12-09 04:36:02
问题 I build a very large POI workbook, on my web server. Holding the entire workbook in memory , will not scale for multiple concurrent requests. Is there a way i can progressively write the workbook to the servlet output stream. That should reduce the response time , as well as make the process memory efficient. 回答1: If you are about to generate Excel 2007 (xslx) then you could adapt the approach of BigGridDemo.java as described here: http://web.archive.org/web/20110821054135/http://www

Setting a part of the cell contents to bold using apache poi?

无人久伴 提交于 2019-12-09 02:59:22
问题 How can i put this string in to a cell using java apache poi? The string is "Hello world Hello" As u can see i need to make a part of the text bold? I'm able to set the entire contents of the cell to bold but not specific parts. Please help me. 回答1: This is probably what you are looking for: http://poi.apache.org/spreadsheet/quick-guide.html#DrawingShapes Find this in the explanation: It's possible to use different fonts to style parts of the text in the textbox. Here's how: HSSFFont font =

MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence

折月煮酒 提交于 2019-12-09 02:13:50
问题 I have a xml file which contains arabic characters.When i try to parse a file,it arise the Exception,MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.I Use POI DOM for parse the document. The Log is, 2012-03-19 11:30:00,433 [ERROR] (com.infomindz.remitglobe.bll.remittance.BlackListBean) - Error com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader

Spacing and Margin settings in MS Word document using Apache POI docx

自古美人都是妖i 提交于 2019-12-09 01:50:39
问题 I have two paragraphs and i want 100 pt space before each line. Is there a way we can do in Apache POI ? Here is the code snippet XWPFDocument doc = new XWPFDocument(); XWPFParagraph documentTitle = doc.createParagraph(); documentTitle.setAlignment(ParagraphAlignment.CENTER); XWPFRun run = documentTitle.createRun(); run.setText("Paragraph 1"); run.setBold(true); run.setFontFamily("Calibri"); run.setFontSize(13); run.setColor("4F81BD"); run.addBreak(); run.setText("Paragraph 2"); run.setBold

How to read from merged cells of Excel in Java using Apache POI?

吃可爱长大的小学妹 提交于 2019-12-08 22:28:59
问题 I have a Excel file in .xlsx format. I have stored data by merging cells to form various columns. I am reading the Excel file via a Java web application and saving its data to a database (MySQL). But when I read from merged cells I get null values along with what are stored in the columns as well as the headers. I am using Apache POI. My code is: public static void excelToDBLogIN() { FileInputStream file = null; Boolean flag = true; ArrayList<String> rows = new ArrayList<String>(); try { //

Extracting MS Word Table Cell as image?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 22:01:09
问题 I need to extract table cells as images. The cells may contain mixed content (Text + Image), which I need to merge into a single image. I am able to get the core text but I have no idea to get an image+text. Not sure if Apace POI would help. Has anyone done something like this earlier? public static void readTablesDataInDocx(XWPFDocument doc) { int tableIdx = 1; int rowIdx = 1; int colIdx = 1; List table = doc.getTables(); System.out.println("==========No Of Tables in Document================