jxl

jxl读取excel文件异常:Unable to recognize OLE stream 的解决方法

若如初见. 提交于 2019-12-02 04:40:47
问题成因 使用jxl方式读取,可能只能支持xls格式的文件,对于xlsx格式就不再支持 如果是从网站导出的excel文件,有的网站比较坑,导出的并不是标准格式的excel,而是将html改扩展名为xls的“伪”excel文件。当用excel打开这类文件时,会弹窗提示其“扩展名和文件类型不匹配”是否还要打开。 而且,使用文本编辑器打开,会发现这个所谓xls文件其实是xml标签的文件。 解决方法 在excel中打开,另存成xls就可以。 但当文件比较多时,可以使用excel vba批量另存 。 第一种情况直接用vba批量另存即可,但第二种略有麻烦,因为会有报错弹窗,vba运行时会报错。 下面以第二种情况为例详细说明解决步骤。 首先,需要 禁止excel的报错弹窗 ,否则使用vba批量另存时会出错。方法如下: 1 1、开始 -> 运行 -> 输入regedit -> 确定 2 2、找到注册表子项 3 4 HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security 5 6 3、在右侧空白处点击鼠标右键,选择“新建 -> DWORD值(D)”,输入"ExtensionHardening"点击确定。 7 4、用鼠标右键点击ExtensionHardening,然后单击“修改(M)”,在数值数据中填写"0"即可确定。 8 5

Problem when using JXL Formula like SUM() AVG() STDEV() returns #VALUE! when it refers values from another sheet

烈酒焚心 提交于 2019-12-01 18:51:00
I want to populate some values in a sheet and then use jxl Formula to get the values from that sheet and write it to another sheet... When I try to run this sample code String filename = "C:\\input.xls"; WorkbookSettings ws = new WorkbookSettings(); ws.setLocale(new Locale("en", "EN")); WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws); WritableSheet s = workbook.createSheet("Input", 0); WritableSheet s1 = workbook.createSheet("Output", 1); s1.addCell(new Number(3, 0, 5)); s1.addCell(new Number(3, 1, 6)); s1.addCell(new Number(3, 2, 1)); s1.addCell(new Number(3, 3, 6)

JAVA - Out Of Memory Error while writing Excel Cells in jxl

左心房为你撑大大i 提交于 2019-12-01 11:57:46
I am using JXL to write an excel file of 50000 rows and 30 columns. My code looks like this: for (int j = 0; j < countOfRows; j++) { myWritableSheet.addCell(new Label(0, j, myResultSet.getString(1), myWritableCellFormat)); myWritableSheet.addCell(new Label(1, j, myResultSet.getString(2), myWritableCellFormat)); ..... ..... } While writing the cells, the program goes slower and slower and finally around the row 25000 I am getting the following error: Exception in thread "Thread-3" java.lang.OutOfMemoryError: Java heap space at jxl.write.biff.WritableSheetImpl.getRowRecord(WritableSheetImpl.java

JAVA - Out Of Memory Error while writing Excel Cells in jxl

被刻印的时光 ゝ 提交于 2019-12-01 09:48:50
问题 I am using JXL to write an excel file of 50000 rows and 30 columns. My code looks like this: for (int j = 0; j < countOfRows; j++) { myWritableSheet.addCell(new Label(0, j, myResultSet.getString(1), myWritableCellFormat)); myWritableSheet.addCell(new Label(1, j, myResultSet.getString(2), myWritableCellFormat)); ..... ..... } While writing the cells, the program goes slower and slower and finally around the row 25000 I am getting the following error: Exception in thread "Thread-3" java.lang

Jexcel Formula Calculation Error

▼魔方 西西 提交于 2019-12-01 08:40:50
I have created a worksheet, out.xls which had cell D6=D5*2 and D5 set to 1. My issue is that when I plug a value into D5 in jxl, D6 never calculates. D6 simply holds on the value it initially calculated when I plugged in 1 to D5 in excel. note: I have a much larger programming problem that I am trying to tackle, this is just a very scaled down version to reduce error. This is my first time ever use Jexcel and I only just learned java this last year, so any help would be appreciated. I spent 6 hours yesterday trying to find an answer on the web, but to no avail. the output is attached below the

Jexcel Formula Calculation Error

白昼怎懂夜的黑 提交于 2019-12-01 06:40:51
问题 I have created a worksheet, out.xls which had cell D6=D5*2 and D5 set to 1. My issue is that when I plug a value into D5 in jxl, D6 never calculates. D6 simply holds on the value it initially calculated when I plugged in 1 to D5 in excel. note: I have a much larger programming problem that I am trying to tackle, this is just a very scaled down version to reduce error. This is my first time ever use Jexcel and I only just learned java this last year, so any help would be appreciated. I spent 6

Copy sheet with JXL in Java

心不动则不痛 提交于 2019-11-30 15:48:43
问题 I would like to copy a sheet from an existing XLS document to a new one to a new location. How could I do this with JXL? Workbook w1 = Workbook.getWorkbook(new File("ExistingDocument.xls"), settings); WritableWorkbook w2 = Workbook.createWorkbook(new File("NewDocument.xls")); /* So here, I would like copy the first sheet from w1 to the second sheet of w2 ... */ w2.write(); w2.close(); w1.close(); edit: w1.getSheet(0).getCell(0, 0) is not a WritableCell , so I couldn't use the copyTo method.

Copy sheet with JXL in Java

こ雲淡風輕ζ 提交于 2019-11-30 15:41:38
I would like to copy a sheet from an existing XLS document to a new one to a new location. How could I do this with JXL? Workbook w1 = Workbook.getWorkbook(new File("ExistingDocument.xls"), settings); WritableWorkbook w2 = Workbook.createWorkbook(new File("NewDocument.xls")); /* So here, I would like copy the first sheet from w1 to the second sheet of w2 ... */ w2.write(); w2.close(); w1.close(); edit: w1.getSheet(0).getCell(0, 0) is not a WritableCell , so I couldn't use the copyTo method. Is there any way to add a cell/sheet from w1 to w2 workbook? edit2: So do I have to create a writable

JXL Cell Formatting

亡梦爱人 提交于 2019-11-30 10:52:20
How to autofit content in cell using jxl api? clang1234 I know this is an old question at this point, but I was looking for the solution to this and thought I would post it in case someone else needs it. CellView Auto-Size I'm not sure why the FAQ doesn't mention this, because it very clearly exists in the docs. My code looked like the following: for(int x=0;x<c;x++) { cell=sheet.getColumnView(x); cell.setAutosize(true); sheet.setColumnView(x, cell); } c stores the number of columns created cell is just a temporary place holder for the returned CellView object sheet is my WriteableSheet object

Writing to an Existing Excel File

白昼怎懂夜的黑 提交于 2019-11-30 09:35:33
package jexcel.jxl.nimit; import java.awt.Label; import java.io.File; import java.io.IOException; import jxl.Cell; import jxl.CellType; import jxl.LabelCell; import jxl.NumberCell; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; import jxl.write.WritableCell; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import jxl.write.WriteException; import jxl.write.biff.RowsExceededException; public class ExcelJxl { /** * @param args * @throws IOException * @throws BiffException * @throws WriteException * @throws RowsExceededException */ public static void