[C#] 纯文本查看 复制代码
context.Response.Clear();
context.Response.AddHeader("Content-Dis ...[/quote]
我贴段代码你看看
[mw_shl_code=html,true]protected void btnExport_Click(object sender, EventArgs e)
{
if (File.Exists(pptFileName))
{
pi = 0;
string[] photopath = new string[16];
DataSet ds = WQWuXiFO.getPPTimg("tblwxjsz", new string[] { "zd=2" }, "D4", Convert.ToDateTime(txtStartDate.Text.Trim()), "dt");
photopath[0] = draw(ds, new string[] { "溶解氧", "D4" }, "dt", "samplename", "望亭自动站");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='虞义大桥'", "samplename='常熟枢纽闸内'", "samplename='张桥'", "samplename='大桥角新桥'", "samplename='望亭立交闸下'" }, "ph", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[1] = draw(ds, new string[] { "溶解氧", "PH" }, "wqdate", "samplename", "望虞河干流");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='大义桥'", "samplename='新师桥'", "samplename='鸟嘴渡'", "samplename='大坊桥'" }, "ph", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[2] = draw(ds, new string[] { "溶解氧", "PH" }, "wqdate", "samplename", "望虞河西岸支流");
ds = WQWuXiFO.getPPTimg("tblwxjsz", new string[] { "zd=2" }, "D8", Convert.ToDateTime(txtStartDate.Text.Trim()), "dt");
photopath[3] = draw(ds, new string[] { "高锰酸盐指数", "D8" }, "dt", "samplename", "望亭自动站");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='虞义大桥'", "samplename='常熟枢纽闸内'", "samplename='张桥'", "samplename='大桥角新桥'", "samplename='望亭立交闸下'" }, "CODmn", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[4] = draw(ds, new string[] { "高锰酸盐指数", "CODmn" }, "wqdate", "samplename", "望虞河干流");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='大义桥'", "samplename='新师桥'", "samplename='鸟嘴渡'", "samplename='大坊桥'" }, "CODmn", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[5] = draw(ds, new string[] { "高锰酸盐指数", "CODmn" }, "wqdate", "samplename", "望虞河西岸支流");
ds = WQWuXiFO.getPPTimg("tblwxjsz", new string[] { "zd=2" }, "D12", Convert.ToDateTime(txtStartDate.Text.Trim()), "dt");
photopath[6] = draw(ds, new string[] { "总磷", "D12" }, "dt", "samplename", "望亭自动站");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='虞义大桥'", "samplename='常熟枢纽闸内'", "samplename='张桥'", "samplename='大桥角新桥'", "samplename='望亭立交闸下'" }, "TP", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[7] = draw(ds, new string[] { "总磷", "TP" }, "wqdate", "samplename", "望虞河干流");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='大义桥'", "samplename='新师桥'", "samplename='鸟嘴渡'", "samplename='大坊桥'" }, "TP", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[8] = draw(ds, new string[] { "总磷", "TP" }, "wqdate", "samplename", "望虞河西岸支流");
ds = WQWuXiFO.getPPTimg("tblwxjsz", new string[] { "zd=1" }, "D8", Convert.ToDateTime(txtStartDate.Text.Trim()), "dt");
photopath[9] = draw(ds, new string[] { "高锰酸盐指数", "D8" }, "dt", "samplename", "贡湖自动站");
ds = WQWuXiFO.getPPTimg("tblwxjsz", new string[] { "zd=1" }, "D10", Convert.ToDateTime(txtStartDate.Text.Trim()), "dt");
photopath[10] = draw(ds, new string[] { "氨氮", "D10" }, "dt", "samplename", "望亭自动站");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='虞义大桥'", "samplename='常熟枢纽闸内'", "samplename='张桥'", "samplename='大桥角新桥'", "samplename='望亭立交闸下'" }, "Ammonia", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[11] = draw(ds, new string[] { "氨氮", "Ammonia" }, "wqdate", "samplename", "望虞河干流");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='大义桥'", "samplename='新师桥'", "samplename='鸟嘴渡'", "samplename='大坊桥'" }, "Ammonia", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[12] = draw(ds, new string[] { "氨氮", "Ammonia" }, "wqdate", "samplename", "望虞河西岸支流");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='锡东水厂取水口'", "samplename='贡湖水厂取水口'", "samplename='金墅湾水厂取水口'" }, "Ammonia", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[13] = draw(ds, new string[] { "高锰酸盐指数", "Ammonia" }, "wqdate", "samplename", "贡湖水源地");
ds = WQWuXiFO.getPPTimg("tblwxjsz", new string[] { "zd=5" }, "D10", Convert.ToDateTime(txtStartDate.Text.Trim()), "dt");
photopath[14] = draw(ds, new string[] { "氨氮", "D10" }, "dt", "samplename", "太浦闸站");
ds = WQWuXiFO.getPPTimg("tblwqwuxi", new string[] { "samplename='太浦闸下'", "samplename='平望大桥'", "samplename='金泽'" }, "Ammonia", Convert.ToDateTime(txtStartDate.Text.Trim()), "wqdate");
photopath[15] = draw(ds, new string[] { "氨氮", "Ammonia" }, "wqdate", "samplename", "太浦河水质");
string filename = "值班专题演示材料" + CurrentUser.Id.ToString() + "," + DateTime.Now.ToString("yyyyMMddHHmmss") + ".ppt";
string newfile = Server.MapPath("~/Upload/PresentationDocument/") + filename;
strfilepath = newfile;
if (File.Exists(newfile))
{
File.Delete(newfile);
}
File.Copy(pptFileName, newfile);
searchPPT(WQWuXiFO.GetPPTSource(txtStartDate.Text.Trim(), txtEndDate.Text.Trim() + " 23:59:59", "Keyword"), WQWuXiFO.GetPPTSource(txtStartDate.Text.Trim(), txtEndDate.Text.Trim() + " 23:59:59", null), newfile, photopath);
//searchPPTPic(photopath, newfile);
if (pager.SortConditions.Count < 1)
{
SortCondition item = new SortCondition();
item.SortDirection = SLinker.Model.Search.SortDirection.Ascending;
item.SortField = "GenDate";
pager.SortConditions.Push(item);
}
IList<PresentationDocumentEntity> il = PresentationDocumentFO.GetPresentationDocumentList(pager, null);
if (il.Count > 50)
{
PresentationDocumentFO.DeletePresentationDocument(il[0].ID.ToString());
}
pdentity = PresentationDocumentFO.GetPresentationDocumentByFileName(filename);
//信息存到数据库
pdentity.DocumentName = filename;
pdentity.StartDate = Convert.ToDateTime(txtStartDate.Text);
pdentity.EndDate = Convert.ToDateTime(txtEndDate.Text);
pdentity.GenDate = DateTime.Now;
pdentity.GenUser = CurrentUser.Id;
PresentationDocumentFO.SavePresentationDocument(pdentity);
BindListData();
//Response.Flush();
//System.IO.FileInfo file = new System.IO.FileInfo(newfile);
//Response.Clear();
//Response.Charset = "GB2312";
//Response.ContentEncoding = System.Text.Encoding.UTF8;
//// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
//Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
//// 添加头信息,指定文件大小,让浏览器能够显示下载进度
//Response.AddHeader("Content-Length", file.Length.ToString());
//// 指定返回的是一个不能被客户端读取的流,必须被下载
//Response.ContentType = "application/ms-excel";
//// 把文件流发送到客户端
//Response.WriteFile(file.FullName);
//// 停止页面的执行
//Response.End();
ClientScript.RegisterStartupScript(Page.GetType(), "sc", "<script>upfile();</script>");
}
}
#region===========操作方法==============
private void searchPPT(string[] Keyword, string[] Keywordvalue, string pptFileName, string[] Piclist)//在指定的ppt文档中搜索keyWord
{
//其中Presentation代表一个 PowerPoint 文档,Slide表示PowerPoint文档中的单张幻灯片
//TextFrame是幻灯片上的文本框,TextRange是文本框中的文本。
pa = null;
pp = null;
bool[] found = new bool[Keyword.Length];
bool[] img = new bool[Piclist.Length];
int foundCount = 0;
int founcimg = 0;
for (int i = 0; i <= found.Length - 1; i++)
{
found = false;
}
for (int i = 0; i <= img.Length - 1; i++)
{
img = false;
}
//try
//{
//打开ppt文档
pa = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
pp = pa.Presentations.Open(pptFileName,
Microsoft.Office.Core.MsoTriState.msoTrue,
Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse);