ITPub博客

首页 > Linux操作系统 > Linux操作系统 > .net经典网站收藏

.net经典网站收藏

原创 Linux操作系统 作者:fangqm 时间:2010-09-20 10:41:45 0 删除 编辑
http://www.pin5i.com最新编程信息
在线PS处理
 

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

            }

        }

    }

}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23109131/viewspace-674456/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
创业项目 https://u.rscode.cn

注册时间:2010-03-24

  • 博文量
    297
  • 访问量
    784645