我有一種情況,必須通過將轉發器導出到Word文檔來生成MS Word報告。我這樣做,但我的要求是將MS Word文件保存在服務器/數據庫。如何在生成Word文檔後將該文件保存在服務器/數據庫中?將轉發器導出到MS Word並保存服務器或數據庫C#上的Word文件,ASP.NET
要求是生成並將Word文件保存在服務器/數據庫上,並且生成或保存的文件也應該是隻讀文件。我該怎麼做 ?
這裏是我使用生成的Word文件中的代碼..
protected void DisplayRepeater()
{
if (ddlDivRAHQ.SelectedValue == "DIV")
{
Repeater_PrintFinalReport.DataSource = new ReportItems().Get_Rpt_Items_Div_Chief(Convert.ToInt32(Session["UserNumber"]), DateTime.Parse(Session["ReportStartDate"].ToString()), DateTime.Parse(Session["ReportEndDate"].ToString()), ddlDivRAHQ.SelectedValue.ToString()).OrderBy(x => x.OrgNum).ThenBy(x => x.Office_Location).ThenBy(x => x.Site_Desc).ToList();
}
else
{
Repeater_PrintFinalReport.DataSource = new ReportItems().Get_Rpt_Items_Div_Chief(Convert.ToInt32(Session["UserNumber"]), DateTime.Parse(Session["ReportStartDate"].ToString()), DateTime.Parse(Session["ReportEndDate"].ToString()), ddlDivRAHQ.SelectedValue.ToString()).Where(x=>x.Finalized == 1).OrderBy(x => x.Site_Desc).ToList();
}
Repeater_PrintFinalReport.DataBind();
Repeater_PrintFinalReport.Visible = true;
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" + ddlDivRAHQ.SelectedValue + "_WeeklyReport_" + DateTime.Now.ToShortDateString() + ".doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Repeater_PrintFinalReport.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
Atleast是否可以生成ReadOnly Word文件? – msbyuva