jxl

java.io.FileNotFoundException when image file is inside jar using jxl.write.WritableImage

给你一囗甜甜゛ 提交于 2019-12-06 15:36:55
I am using WritableImage to write image into xls file, when I run it inside eclipse it is working fine. But when I run it in executable jar, I getting FileNotFoundException. WritableImage image = new WritableImage(0.0D, 0.0D, 1.0D, 3.0D, new File(getClass().getResource("/img/abouts.png").getPath())); The image is indeed inside the jar. C:\scheduler-1.0-SNAPSHOT-jar-with-dependencies.jar\img\abouts.png Here's the exception: java.io.FileNotFoundException: file:C:<some directory>scheduler-1.0-SNAPSHOT-jar-with-dependencies.jar!/scheduler.jar!/img/abouts.png (No such file or directory) at java.io

Password protected xls/xlsx file in java

僤鯓⒐⒋嵵緔 提交于 2019-12-06 07:18:08
I have created password protected zip file which has xls file with the help of this http://java.sys-con.com/node/1258827 . My question is ,Is there any java api which will create password protected xls file instead of zip file. I want to directly apply password on xls file.Encryption/Decryption is the option but want to prompt when when double clicked on file. edit: I got this HSSFSheet.protectSheet("xyz"); but it only makes sheet read only. Even I have tried this hssfworkbook.writeProtectWorkbook("abc", "abc"); but its not prompting for password. Edit1:There is the method in org.apache.poi

Viewing Excel files in my Android App through API

て烟熏妆下的殇ゞ 提交于 2019-12-06 02:28:49
I want to view excel files in my own Android App. Currently, using my App I can see all google docs. But after clicking on any one doc (for e.g Excel file 'myDemo.xls') , I want to open it in my own app (For Viewing purpose). I have read about jxl but the problem with this is that it parses the xls file & the file should be stored in the SD Card. In my case it is stored in the google drive. (not on SD card) Here is similar question. Is there any other way to view xls file through any other API. Any help will be appreciated. Thanks I have used the WebView to achieve this. But the problem is ,

struts 2 Can not find a java.io.InputStream with the name [excelStream] in the invocation stack

こ雲淡風輕ζ 提交于 2019-12-05 18:23:11
excelStreamI am trying to download an excel file. In my Action class public class ActivityTrackerExlReportAction extends BaseAction { private InputStream excelStream; private UserMasterDTO userMasterDTO; public InputStream getExcelStream() { return excelStream; } public void setExcelStream(InputStream excelStream) { this.excelStream = excelStream; } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); WorkbookSettings wbSettings = new WorkbookSettings(); try { response.setHeader("Content-Disposition", "attachment; filename=/timesheet.xls"); wbSettings.setLocale(new Locale("en",

Get Excel SheetNames using POI jar

我的未来我决定 提交于 2019-12-05 10:52:04
I need all Excel sheet Names (what r all contains the datas) using POI jar. Like jxl jar - getSheetNames() You don't say how you want them, so I'll guess at a list. You just need to iterate over the sheet indicies, getting the name for each. Your code would be something like: File myFile = new File("/path/to/excel.xls"); Workbook wb = WorbookFactory.create(myFile); List<String> sheetNames = new ArrayList<String>(); for (int i=0; i<wb.getNumberOfSheets(); i++) { sheetNames.add( wb.getSheetName(i) ); } 来源: https://stackoverflow.com/questions/12600883/get-excel-sheetnames-using-poi-jar

java读写excel之POI篇—001

为君一笑 提交于 2019-12-05 10:38:30
POI 简单介绍 Apache POI是 Apache软件基金会 的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能。 Apache POI 是创建和维护操作各种符合Office Open XML(OOXML)标准和微软的OLE 2复合文档格式(OLE2)的Java API。用它可以使用Java读取和创建,修改MS Excel文件.而且,还可以使用Java读取和创建MS Word和MSPowerPoint文件。Apache POI 提供Java操作Excel解决方案。 如果处理.xlsx、docx、pptx的话可以试试Docx4j 。 Docx4j is a Java library for creating and manipulating Microsoft Open XML (Word docx, Powerpoint pptx, and Excel xlsx) files. 基本功能 HSSF - 提供读写Microsoft Excel XLS格式档案的功能。 XSSF - 提供读写Microsoft Excel OOXML XLSX格式档案的功能。 HWPF - 提供读写Microsoft Word DOC格式档案的功能。 HSLF - 提供读写Microsoft PowerPoint格式档案的功能。 HDGF -

Insert image to excel file using JXL without stretching it

谁都会走 提交于 2019-12-05 03:30:27
I can insert image to my excel file using jxl using sheet.addImage(WritableImage obj) . My problem is that, it stretches based on the args of WritableImage . I'm wondering if there is a way so that the image that I insert will not stretch like if I insert a 200x200 sized image it will appear to the sheet as 200x200. king14nyr As much as this has bugged me about jxl, I've never found a way to insert an image without associating the aspect ratio to cells instead of pixels/inches/any standard unit of measurement, and I've done decent research in the past on doing so. The best you can do is to

JXL Number Format and Cell Type

人走茶凉 提交于 2019-12-05 01:42:50
I am using JXL to write an Excel file. The customer wants a certain column to display numbers with one decimal place. They also want the cell types to be "Number". When I use the following (test) code, the numbers are displayed correctly, but the cell type is "Custom". File excelFile = new File("C:\\Users\\Rachel\\Desktop\\TestFile.xls"); WritableWorkbook excelBook = Workbook.createWorkbook(excelFile); WritableSheet excelSheet = excelBook.createSheet("Test Sheet", 0); WritableFont numberFont = new WritableFont(WritableFont.ARIAL); WritableCellFormat numberFormat = new WritableCellFormat

Android操作文档系列2- 操作Excel

孤人 提交于 2019-12-04 23:16:31
1 开发调研 1.1 需求描述 MS的电子表格(Excel)是Office的重要成员,是保存统计数据的一种常用格式。作为办公文档,势必要涉及到的电子文档的交换,Excel是一种在企业中非常通用的文件格式,打印和管理也比较方便。在一个Java应用中,将一部分数据生成Excel格式,是与其他系统无缝连接的重要手段。 1.2 Excel开发常用开源工具 在开源世界中,有两套比较有影响的API可供使用,一个是POI,一个是jExcelAPI。 1.3 比较开源工具的优缺点 1.3.1 Jxl优缺点 Jxl特征有如下描述: ● 支持Excel 95-2000的所有版本 ● 生成Excel 2000标准格式 ● 支持字体、数字、日期操作 ● 能够修饰单元格属性 ● 支持图像和图表 应该说以上功能已经能够大致满足我们的需要。最关键的是这套API是纯Java的,并不依赖Windows系统,即使运行在Linux下,它同样能够正确的处理Excel文件。另外需要说明的是,这套API对图形和图表的支持很有限,而且仅仅识别PNG格式。 1.3.2 Poi优缺点 Jakarta 的 POI Project 与 Java Excel API 在开源世界中可以说是并驾齐驱,但是也各有优劣,poi在某些细节有些小Bug并且不支持写入图片(poi其实可以写入图片,不过没有jxl来的方便,比较麻烦),其他方面都挺不错的

JAVA利用JXL导出/生成 EXCEL

℡╲_俬逩灬. 提交于 2019-12-04 14:38:17
在开发中很多时间需要导出数据库中的一些数据到excel中!昨天就研究了一下……用JXL导出excel /** * 导出导出采暖市场部收入、成本、利润明细表 * @author JIA-G-Y */ public String exporExcel(String str) { String path = str + "收入、成本、利润明细表.xls"; try { List<WholesaleAgreementMaterialExportExcelTemplate> list = agreementDao.selectAllWholeDetails(); // 打开文件 WritableWorkbook book = Workbook.createWorkbook( new File(path)); // 生成名为“第一页”的工作表,参数0表示这是第一页 WritableSheet sheet = book.createSheet( " 第一页 " , 0 ); SheetSettings ss = sheet.getSettings(); // ss.setHorizontalFreeze(2); // 设置列冻结 ss.setVerticalFreeze(2); // 设置行冻结前2行 WritableFont font1 =new WritableFont