.net经典网站收藏

http://www.pin5i.com最新编程信息
在线PS处理
http://www.sumopaint.com/app/
http://www.webps.cn/
 

MyXLS 是一个快速和简单的读写 Excel 文件的 .NET 组件,可用在 ASP.NET 网站和 .NET 应用程序中,无需安装 Excel 程序,支持 Excel 97 以及以后的版本。

示例代码:

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();

**************************************

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

using org.in2bits.MyXls;


namespace MyXls.SL3.Test

{

    public partial class Page : UserControl

    {

        public Page()

        {

            InitializeComponent();

        }


        private void WriteXlsButton_Click(object sender, RoutedEventArgs args)

        {

            var xls = new XlsDocument();

            var sheet = xls.Workbook.Worksheets.Add("Test Sheet");

            sheet.Cells.Add(1, 1, "Hello, World!");

            var sfd = new SaveFileDialog();

            sfd.DefaultExt = ".xls";

            var result = sfd.ShowDialog();

            if (result ?? false)

            {

                using (var s = sfd.OpenFile())

                    xls.Save(s);

            }

        }

    }

}


请使用浏览器的分享功能分享到微信等