⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savetooffice.aspx.cs

📁 iWEbOffice2006协同办公中间件
💻 CS
字号:
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


namespace  iWebOffice.ocx.c.net
{
	/// <summary>
	/// OfficeServer 的摘要说明。
	/// </summary>
	public class SaveToOffice : System.Web.UI.Page
	{
		private byte[] mFileBody;
		private string mFileName;

		private string mFilePath;
		private string strSelectCmd;
		private string mRecordID;
		
		private DBstep.iMsgServer2000 MsgObj;
		private iDBManage2000 DBAobj;

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面

		  	DBAobj=(iDBManage2000)Session["DBDemo"];			
			MsgObj = new DBstep.iMsgServer2000();
			mFilePath=Server.MapPath(".");
			mRecordID=Request.QueryString["RecordID"];
			if(mRecordID==null )
			{
				strSelectCmd="SELECT top 1 FileName,FileBody FROM Document_File";
			}
			else
			{
				strSelectCmd="SELECT FileName,FileBody FROM Document_File WHERE RecordID='" + mRecordID + "'";
			}
			if(LoadFile())
			{
				MsgObj.MsgFileBody(MsgObj.ToDocument(mFileBody));
				if(MsgObj.MsgFileSave(mFilePath+"\\"+mFileName))
				{
					Response.Write("成功:在服务器生成OFFICE文档" + mFilePath + "\\" + mFileName) ; 
				}
				else
				{
					Response.Write("在服务器上生成Office文档失败!") ;
				}
			}
			else
			{
				Response.Write("取得服务器文档数据失败!") ;
			}
			
		}
		//调出文档,将文档内容保存在mFileBody里,以便进行打包
		private bool LoadFile()
		{
			bool mResult=false;
			SqlCommand mCommand = new SqlCommand(strSelectCmd,DBAobj.Connection);
			SqlDataReader mReader = mCommand.ExecuteReader();
			if (mReader.Read())
			{
				mFileBody=mReader.GetSqlBinary(1).Value; 
				mFileName=mReader["FileName"].ToString();
				mResult=true;
			}
			else
			{
				mResult=false;
			}
			mReader.Close();
			return (mResult);
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -