.Net 第三方库运用:ClosedXML

  • 什么是Closed Xml

  1. ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).

  • 哪里下载

  1. Please refer to https://github.com/ClosedXML/ClosedXML to download the latest code
  • 如何使用

  • How to create a simple excel sheet file
      public void Create(String filePath)
      {
         var workbook = new XLWorkbook();
         var worksheet = workbook.Worksheets.Add("Sample Sheet");
         worksheet.Cell("A1").Value = "Hello World!";
         workbook.SaveAs(filePath);
      }
    
    The sample code demonstrate how to create a very simple excel sheet file. First, you need to create a workbook--XLWorkbook , then add a new sheet, then set value to cell: ‘A1’, then save to a specific path.

  • 2. How to create basic table:
    public void Create(string filePath)
            {
                // Creating a new workbook
                var wb = new XLWorkbook();
    
                //Adding a worksheet
                var ws = wb.Worksheets.Add("Contacts");
    
                //Adding text
                //Title
                ws.Cell("B2").Value = "Contacts";
                //First Names
                ws.Cell("B3").Value = "FName";
                ws.Cell("B4").Value = "John";
                ws.Cell("B5").Value = "Hank";
                ws.Cell("B6").Value = "Dagny";
                //Last Names
                ws.Cell("C3").Value = "LName";
                ws.Cell(&
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值