jxl.dll操作总结
1)Jxl是一个开源的Java Excel API项目,通过Jxl,Java可以很方便的操作微软的Excel文档。除了Jxl之外,还有Apache的一个POI项目,也可以操作Excel,两者相比之下:Jxl使用方便,但功能相对POI比较弱。
2)jxl.dll据说是一个韩国人写的,并且是用java语言写的。是通过一个ikvm的工具转换为jxl.dll供windows平台使用的。具体可以参照下面两个链接内容:
http://www.splinter.com.au/using-java-libraries-in-a-c-app-with-ikvm/
http://blog.csdn.net/kingdax1/article/details/2679610
3)并且jxl不支持excel2007及以上的版本。
4)简要使用方法如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using jxl;
using jxl.write;
namespace ExcelWrap
{
/// <summary>
/// jxl.dll帮助类
/// 说明:jxl不支持excel2007以上格式
/// </summary>
public class JxlHelper
{ public static void ReadExcel(string ExcelPath)
{ try { //Create a workbook object from the file at specified location.
//Change the path of the file as per the location on your computer.
Workbook wrk1 = Workbook.getWorkbook(new FileInfo(ExcelPath)); //Obtain the reference to the first sheet in the workbook
Sheet sheet1 = wrk1.getSheet(); //Obtain reference to the Cell using getCell(int col, int row) method of sheet
Cell colArow1 = sheet1.getCell(, );
Cell colBrow1 = sheet1.getCell(, );
Cell colArow2 = sheet1.getCell(, ); //Read the contents of the Cell using getContents() method, which will return
//it as a String
String str_colArow1 = colArow1.getContents();
String str_colBrow1 = colBrow1.getContents();
String str_colArow2 = colArow2.getContents(); //Display the cell contents
System.Console.WriteLine("Contents of cell Col A Row 1: \""+str_colArow1 + "\"");
System.Console.WriteLine("Contents of cell Col B Row 1: \""+str_colBrow1 + "\"");
System.Console.WriteLine("Contents of cell Col A Row 2: \"" + str_colArow2 + "\""); }
catch (jxl.read.biff.BiffException e)
{
Console.WriteLine(e.StackTrace);
} catch (IOException e) {
Console.WriteLine(e.StackTrace);
} } public static void WriteExcel(string ExcelPath)
{
try {
FileInfo exlFile = new FileInfo(ExcelPath);
WritableWorkbook writableWorkbook = Workbook
.createWorkbook(exlFile); WritableSheet writableSheet = writableWorkbook.createSheet(
"Sheet1", ); //Create Cells with contents of different data types.
//Also specify the Cell coordinates in the constructor
Label label = new Label(, , "Label (String)");
System.DateTime dt = System.DateTime.Now;
jxl.write.DateTime date = new jxl.write.DateTime(, , ref dt);
jxl.write.Boolean bl = new jxl.write.Boolean(, , true);
Number num = new Number(, , 9.99); //Add the created Cells to the sheet
writableSheet.addCell(label);
writableSheet.addCell(date);
writableSheet.addCell(bl);
writableSheet.addCell(num); //Write and close the workbook
writableWorkbook.write();
writableWorkbook.close(); } catch (IOException e) {
Console.WriteLine(e.StackTrace);
} catch (jxl.write.biff.RowsExceededException e) {
Console.WriteLine(e.StackTrace);
} catch (WriteException e) {
Console.WriteLine(e.StackTrace);
}
}
}
}
5)其他的使用方法可以参考java实现的例子。网上关于java的例子还是挺多的。之前我并不知道它是通过java转换而来的,也没有可以使用的例子,只有通过Reflector反编译看源码,慢慢了解。
jxl.dll操作总结的更多相关文章
- c# 使用Renci.SshNet.dll操作SFTP总结
1.操作类 /// <summary> /// SFTP操作类 /// </summary> public class SFTPHelper { #region 字段或属性 p ...
- Asp.Net使用org.in2bits.MyXls.dll操作excel的应用
首先下载org.in2bits.MyXls.dll(自己的在~\About ASP.Net\Asp.Net操作excel) 添加命名空间: using org.in2bits.MyXls;using ...
- C#使用OpcNetApi.dll和OpcNetApi.Com.dll操作OPC
本人学习了一下.Net,恰好,51自学网,又要用这个.而网上很多VC6,VB6,VB .Net的但,很少C#的.现在研究一下,给出例子: 测试平台,是VS2008,KEPServer,OpcNetAp ...
- 跨DLL操作fopen的返回值导致出错
在设置成/MD或/MDd不会导致出错 设置成/MT或/MTd的情况下会导致出错 看了CRT的实现,估计是因为fopen创建了CriticalSection来保护文件,但是在/MT的情况下,一个DLL里 ...
- 使用PLCcom.dll操作西门子系列PLC
工作中经常需要了解plcdb块的数据!由于工作使用OPC类库进行通讯,开发,配置,使用都比较麻烦, 特在网上找到一个名为PLCcom.dll的类库,可以实现PLC读写操作,下面演示C#如何使用PLCc ...
- 使用JXL组件操作Excel和导出文件
这段时间参与的项目要求做几张Excel报表,由于项目框架使用了jxl组件,所以把jxl组件的详细用法归纳总结一下.本文主要讲述了以下内容: JXL及相关工具简介 如何安装JXL JXL的基本操作 创建 ...
- StackExchange.Redis.DLL 操作redis简化版
直接引入StackExchange.Redis.dll来操作redis using Newtonsoft.Json; using StackExchange.Redis; using System; ...
- StackExchange.Redis.DLL 操作redis加强版
直接引用StackExchange.Redis.dll这一个dll来操作redis App.config配置 <?xml version="1.0" encoding=&qu ...
- 使用jxl.jar操作Excel
在工程的build path中添加jxl.jar,网址:http://www.andykhan.com/jexcelapi/ import java.io.BufferedReader; import ...
随机推荐
- 普通委托到泛型委托到Linq
private delegate bool delTest(int a); private void button1_Click(object sender, EventArgs e) { var a ...
- 10个 iOS 用户暂可以嘲笑 Android 的特点
Android 与 iOS 设备之间的争斗从未停止,毕竟一切高科技产品的理念和实际表现方式都不相同.就拿 Android 来说,很多功能令用户并 不太开心,甚至是令人愤怒,下面让我们来简单的盘点 10 ...
- MVC4.0 解决Controllers与Areas中控制器不能同名问题
在使用MVC4.0的时候,难免会遇到在根目录下的Controllers中添加的控制器名称可能会跟在Areas中的某个区域下的控制器名称一样.这个时候访问Areas下面的Controller/Actio ...
- 55.ERROR:Place:1136 - This design contains a global buffer instance…… non-clock load pins off chip
ISE在布局布线时,出现下图所示错误. 对于"clock_dedicated_route”错误原因有两种情况: 1. 就是有一个时钟你没有放到全局时钟或者局部时钟的引脚,布局的时候不能把它 ...
- 使用xilinx ip core FIFO First- World First-Through (FWFT)模式的注意事项
也许很多人知道xilinx ip core 中的fifo可以配成standard 模式和FWFT模式,并知道两者的区别是:standard模式下,当rd为高时,fifo会延时一个时钟输出数据(时序逻辑 ...
- P3245: 最快路线
这道题其实还是不难的,只是自己搞混了=-=//晕,做了好久啊,其实就是个spfa,关键是存储路径搞昏了.输出格式要求太严了,航模不能有空格啊,所以因为格式WA了三次,哭啊/(ㄒoㄒ)/~~.贴上代码吧 ...
- Daily Scrum6
今天我们小组开会内容分为以下部分: part 1: Anti-spam and anti-abuse module模块总结: part 2: 部分优化代码的展示于交流: part 3:针对用户积分模块 ...
- MyEclipse 中的各种有的没的快捷方式
快捷键1 (CTRL) Ctrl+1 快速修复Ctrl+D: 删除当前行 Ctrl+Q 定位到最后编辑的地方 Ctrl+L 定位在某行 Ctrl+O 快速显示 OutLine Ctrl ...
- timersmanager 解析
最近在看crtmp源代码,看到timersmanager 模块时感觉很难理解,花了不少时间反复思考该模块 的逻辑,现在思考的结果记录下来,方便以后查阅. 构造函数中将处理时间方法传进来,将_lastT ...
- 百分比布局实现响应式布局在 IE6 中填坑思路
最近接了个政府项目,政府项目要求响应式,并且兼容IE6,不想用媒体监测的方法,于是用了百分比布局的方法,但是IE6真是名不虚传,做第一个界面就遇到了个bug ①两张宽度各占50%的图片无法在同一横排, ...