当前位置: 代码迷 >> ASP.NET >> 用ASP.NET2.0生成WORD EXCEL文档解决方法
  详细解决方案

用ASP.NET2.0生成WORD EXCEL文档解决方法

热度:9431   发布时间:2013-02-26 00:00:00.0
用ASP.NET2.0生成WORD EXCEL文档
我想用ASP.NET2.0,这样我们的测试报告等就可以在WEB系统上填写,并从系统上生成了

大家有何建议。

我在ASP.NET   1.0时处理不了的就是那些图片等。。。。

------解决方案--------------------------------------------------------
//处理EXCEL 代码是可以运行的

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Win32;
namespace WindowsApplication2
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Button btnLoad;
private System.Windows.Forms.Button btnCreateExcel;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
SqlConnection Conn=new SqlConnection( "server=(local);uid=sa;pwd=sa;database=pubs ");
SqlDataAdapter da;
DataSet ds=new DataSet();
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.btnLoad = new System.Windows.Forms.Button();
this.btnCreateExcel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = " ";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(24, 16);
this.dataGrid1.Name = "dataGrid1 ";
this.dataGrid1.Size = new System.Drawing.Size(304, 184);
this.dataGrid1.TabIndex = 0;
//
// btnLoad
//
this.btnLoad.Location = new System.Drawing.Point(48, 232);
this.btnLoad.Name = "btnLoad ";
this.btnLoad.TabIndex = 1;
this.btnLoad.Text = "加载 ";
this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
//
// btnCreateExcel
//
this.btnCreateExcel.Location = new System.Drawing.Point(176, 232);
this.btnCreateExcel.Name = "btnCreateExcel ";
this.btnCreateExcel.TabIndex = 2;
this.btnCreateExcel.Text = "导入Excel ";
this.btnCreateExcel.Click += new System.EventHandler(this.btnCreateExcel_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(408, 273);
this.Controls.Add(this.btnCreateExcel);
this.Controls.Add(this.btnLoad);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1 ";
this.Text = "Form1 ";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);

}
  相关解决方案