日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

这个世界并不缺少创意,而是缺少发现

發布時間:2025/3/20 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 这个世界并不缺少创意,而是缺少发现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天發現一個比較神奇的Excel組件,純.NET 代碼做的。贊一個先

Overview

MyXLS is a .NET 2.0 library that writes and reads native Excel files quickly and easily, including formatting and multiple sheets. Generate Excel files for ASP.NET sites or .NET applications. Doesn't require Excel on the server or any licensing. Compatible with Excelversions 97 and up. Features
  • Pure .NET code - no P/Invokes, Interop assemblies, or Excel COM automation behind the scenes.
  • No other dependencies - add and reference the MyXls dll in your project and go!
  • Fast! (we will be adding some performance metrics)
  • Lightweight! The dll is only ~100 KB
  • Free to use, no licensing restrictions.
  • Open Source Project
  • The files generated are 100% compatible with Excel versions 97 and up. Files are BIFF8, which is Excel 97-2003's native format, and fully forward compatible with Excel 2007.
  • Create any number of Worksheets
  • Name Worksheets
  • Write values to any cell on any Worksheet - values don't have to be in contiguous ranges
  • Supports a good portion of Excel's formatting capabilities (bold, underline, italic, rotation, etc)
  • Supports writing Metadata - values displayed in Excel's File->Properties dialog box

http://myxls.in2bits.org/wiki/Default.aspx?Page=MainPage&AspxAutoDetectCookieSupport=1

?

Writing an Excel Document

Edit

Basic Example

This example creates a new Excel file, adds a named worksheet, and puts a value into a cell in that worksheet. Very basic but it shows how in six lines of code you can use MyXls to create Excel files.
XlsDocument doc = new XlsDocument(); doc.FileName = "HelloWorld.xls"; Worksheet sheet = doc.Workbook.Worksheets.Add("Hello World Sheet"); Cell cell = sheet.Cells.Add(1, 1, "Hello!"); cell.Font.Weight = FontWeight.Bold;
doc.Save();
Edit

Web Application Support

MyXls has built in support for web applications. Using the XlsDocument.Send() method you can easily send an Excel spreadsheet back to the client.
// Send the document back as an attachement // Same as doc.Send(XlsDocument.SendMethods.Attachment); doc.Send();
// or use // send the document back within the page doc.Send(XlsDocument.SendMethods.Inline);
Edit

Reading an Excel Document

Read support is still relatively experimental. However, MyXls should be able to read all values (even formulas! though you can't write formulas with it yet!) and formatting. It will not read any OLE objects, Pivot Tables, Charts/Graphs, VBA modules, etc. -- it will simply ignore them. It supports only Excel versions 97 thru 2003/XP - 2007's .xlsx XML format is not supported. However, you can try the below to see if it will work for you, and please submit a bug if you have any problems beyond that.
Edit

Basic Example

This example reads various values (including formula results) from an example Excel file, BlankBudgetWorksheet.xls. This does does not show retrieving formatting (font size, borders, etc.), but you should get the basic idea of how to reference the cells on which you would read those other properties:
XlsDocument xls = new XlsDocument(@"c:\Path\To\BlankBudgetWorksheet.xls", null); //read in the Excel file
string worksheet1Name = xls.Workbook.Worksheets0.Name; //Worksheet 1 name : "Budget" string worksheet2Name = xls.Workbook.Worksheets1.Name; //Worksheet 2 name : "Income" string worksheet3Name = xls.Workbook.Worksheets2.Name; //Worksheet 3 name : "Expenses"
Worksheet sheet = xls.Workbook.Worksheets0; //get a reference to a Worksheet
string cellH6HyperlinkText = (string)sheet.Rows6.CellAtCol(8).Value; //Cell H6 hyperlink text : "See reverse for instructions and guidelines" string cellJ7Value = (string)sheet.Rows7.CellAtCol(10).Value; //Cell J7 value : "Budget Plan" string cellG28Value = (string)sheet.Rows28.CellAtCol(7).Value; //Cell G28 value : "Administrative Support (12% of Revenue)" long cellC10Value = (long)sheet.Rows10.CellAtCol(3).Value; //Cell C10 value : 6801 string cellF10FormulaResultValue = (string)sheet.Rows10.CellAtCol(6).Value; //Cell F10 Formula result value : "- 20"

轉載于:https://www.cnblogs.com/chenxizhang/archive/2009/05/22/1487354.html

總結

以上是生活随笔為你收集整理的这个世界并不缺少创意,而是缺少发现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。