Excel文件读写

C#读写Excel的方式有好几种,具体参考文章:

http://www.cnblogs.com/huipengkankan/archive/2011/07/28/2120407.html

昨天大致研究了一下,项目中使用LibXl库进行读写,官方网址:http://libxl.com/home.html,可以支持C#C++DelphiFortran等等,新版可以支持到Excel2013,用起来还是蛮方便的,但是要购买。

破解的也有,可以参考:http://blog.csdn.net/lbd2008/article/details/8332345

里面的函数不多,可以直接参考官方文档,或者看下百度文库

官方小例子:

class Program
{ 
    static void Main(string[] args)
    {
        try 
        {
            Book book = new BinBook(); // use XmlBook() for xlsx
            Sheet sheet = book.addSheet("Sheet1");
            sheet.writeStr(2, 1, "Hello, World !");
            sheet.writeNum(3, 1, 1000);
            book.save("example.xls");    
        }
        catch (System.Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
}
原文地址:https://www.cnblogs.com/zsb517/p/4310308.html