ClosedXML开源项目,创建excel 2007/2010 感觉挺不错

http://closedxml.codeplex.com/

 

Project Description
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).

Request #1: If you like this project please make an entry about it in your blog. The more people who use it the better it gets.

Request #2: If you ever find yourself thinking "I wish this API allowed me to do 'this' easier", please let me know about it. There's only so many scenarios I can think of for using this API. I'm very interested in how people work, how they use this API, and what can be done to make your life easier.

What can you do with this?

ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.

If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.

            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs("HelloWorld.xlsx");


Something more elaborate:

The  Documentation page has an example of how to create the following table ( Showcase) as well as many other examples:

Showcase.jpg

Development Status

The current build has the following capabilities:
  • Can create new workbooks and modify existing ones (from a file or a stream)
  • Add worksheets
  • Access cells using R1C1, A1, and mixed notations.
  • Add text, dates, time spans, booleans, and numbers to cells
  • Select ranges
  • Create Named Ranges
  • Format cells/ranges
    • Alignments
    • Borders
    • Fills
    • Fonts
    • Numeric/Date formats
  • Traverse a range's columns and rows
  • Merge/Unmerge ranges
  • Insert Columns and Rows
  • Adjust row heights and column widths
  • Convert cell's data types
  • Clear and/or delete ranges
  • Select multiple rows and columns
  • Access the entire page setup dialog
  • Add page breaks
  • Transpose ranges
  • Use lambda expressions on pretty much any object/collection/property
  • Adjust row height and column width to their contents
  • Get/set workbook properties
  • Formulas (both A1 and R1C1 notations)
  • Hide/Unhide Row(s)/Column(s)
  • Outline functionality (grouping of rows and columns)
  • Copying data from IEnumerable Collections
  • Copying Ranges
  • Theme colors
  • Freezing Panes
  • Excel Tables
  • Hyperlinks
  • Many more...
Last edited Jan 31 at 10:51 PM by MDeLeon, version 30
这里面有些功能比较实用和吸引人,比如可直接导出固定行列的excel,可以根据行列内容,调整行列的高度和宽度,可格式化单元格内容
转换列的数据类型,插入行列,等等
对.net的一些数据类型和对像也支持的不错,比如list和datatable
具体的内容可看官方网页,另有很多示例代码,非常不错

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值