apache-poi

Convert .xls to csv file using apache poi

有些话、适合烂在心里 提交于 2019-12-13 16:46:48
问题 I have convert .xls to csv file.my code is woring fine.but one issue,I was facing.like some cell value has (xxx,Md) these cell value should consider one value but take two column.how to rectify the problem here ,I have attached my code. try { FileOutputStream fos = new FileOutputStream(outputFile); HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(inputFile)); workbook.setMissingCellPolicy(Row.CREATE_NULL_AS_BLANK); HSSFSheet sheet = workbook.getSheetAt(0); for(int rowIndex = sheet

Why Apache POI XWPFRun.setFontFamily() for cyrillic works wrong?

泄露秘密 提交于 2019-12-13 16:24:26
问题 I try to setFontFamily("Arial") to XWPFRun object with setText("Привет Hello") - cyrillic a english. English text will become Arial after this method call, but Russian text will be still at Colibri font family. How to create right font family for cyrillic text? 回答1: Comment to setFontFamily() says: Specifies the fonts which shall be used to display the text contents of this run. Specifies a font which shall be used to format all characters in the ASCII range (0 - 127) within the parent run To

'OutOfMemoryException' reading 20mb XLSX file

浪尽此生 提交于 2019-12-13 16:22:38
问题 I'm using NPOI to deal with Excel files. Here's how I'm reading files: using (FileStream stream = File.OpenRead(excelFilePath)) { IWorkbook wb = WorkbookFactory.Create(stream); ... } However, for any XLSX file larger than a few megabytes, it causes memory usage to shot up to about 1GB and eventually throw an OOM exception. Doing some research, I've found out that, strangely, loading a workbook from a File rather than a Stream results in less memory consumption by POI. The closest C#

Read a single column of excel sheet using java

烈酒焚心 提交于 2019-12-13 15:11:26
问题 I have an excel sheet. I want to write a method which takes parameter as column number that to be read and return a array consist of all the data in that column. And then to place that column element in xml sheet. How can I write a method to do that? 回答1: Use Apache POI. You can find example in their usage page. Sheet sheet1 = wb.getSheetAt(0); for (Row row : sheet1) { for (Cell cell : row) { // Here you might have to use the cell number to limit what you want. CellReference cellRef = new

How to Add image to image placeholder added in pptx using Apache POI API?

夙愿已清 提交于 2019-12-13 14:51:02
问题 I have predefined pptx template with text and Image place holder, How i can access and modify these placeholder from template. I can add image and text directly to slide using POI pptx API, but how to add same to placeholder of template. 回答1: Refer link to see how to add place holder to create fixed template-- https://support.office.com/en-us/article/Add-a-text-placeholder-with-custom-prompt-text-85048846-c08c-4b7b-8f1a-fb25469903f3 Here is solution--- //read all shapes i.e place holder in

C#. xlsx date cell import to DataTable by NPOI 2.0

十年热恋 提交于 2019-12-13 13:22:46
问题 I'm tried to convert .xlsx file to DataTable format by using NPOI 2.0 library. It's OK, but I have a problem with convert to string date cell. When I try to use construction like row.GetCell(j).ToString() - it's threw exception "Cannot get numeric value from a text cell". I tried to use DateCellValue property, but it also threw this exception. With other cell formats it's work good. Function, that I use it's: private DataTable xlsxToDT(string fileName) { DataTable table = new DataTable();

Excel to Json converter in JAVA

你。 提交于 2019-12-13 12:32:14
问题 Am trying to covert the excel data into JSON format. And i am successful upto converting excel data by reading the rows and columns and set the data to list and then converting that List to JSON format. But, I stuck in next level of JSON where the format will be like Here is the code which iam using, But not yet started how to make that nested data like 3 columns data should come in one array like the above image. Pojo class : public class Products implements Serializable{ @Id @Column(name=

How to shift specific cells using Apache POI?

杀马特。学长 韩版系。学妹 提交于 2019-12-13 12:29:55
问题 My excel sheet contains different regions on the same sheet like: region1: region2: John 2 A 1 John 1 B 2 Sue 1 C 3 Sue 2 D 4 Alice 5 E 5 Bob 1 F 6 I want to add new items into one of these regions without affecting the other regions. I tried using rowShift() method but it is also deleting the complete rows. Is there any way that can shift the specific cells down and can insert rows into the specific regions like this: In my given example I want to add one more row in region1 (also retaining

Can POI or docx4j read Word docs that are password-protected?

霸气de小男生 提交于 2019-12-13 11:24:07
问题 I'm having an issue with POI that I'd like some help with. I have a personal journal that I've kept for years by making daily entries into a Word .doc per month that's stored in a year folder. I add a password to open each one, so they're all encrypted. I want to use Lucene to index the entire collection to allow better searching (e.g. "What day and year did I last write about how much I like oatmeal?"). The first step was to use POI to read a Word .doc, but I can't get off the dime because

ClassNotFoundException in eclipse

独自空忆成欢 提交于 2019-12-13 09:44:04
问题 import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; public void ReadXL(String Path) throws Exception { FileInputStream myStream=null; System.out.println("InReadxl"); File xlFile = new File(Path); myStream = new FileInputStream(xlFile); HSSFWorkbook myWB = new HSSFWorkbook(myStream); ........................... } HSSFWorkbook myWB = new HSSFWorkbook