1  private void ExportDataSet(string fileName, string templatePath, DataSet ds, HttpResponse reponse, FileFormatType FileType= FileFormatType.Xlsx)
 2         {
 3             Aspose.Cells.License Clicense = new Aspose.Cells.License();
 4             string asposePath = Server.MapPath(ConfigurationManager.AppSettings["AsposeLicensePath"]);
 5             //string asposePath = Server.MapPath(@"../Template/Aspose/Aspose.Total.lic");
 6             Clicense.SetLicense(asposePath);
 7 
 8             WorkbookDesigner designer = new WorkbookDesigner();
 9 
10             designer.Open(Server.MapPath(templatePath));
11             designer.SetDataSource(ds);
12 
13             // 生成水印图片
14             Aspose.Cells.Drawing.Shape wordart = designer.Workbook.Worksheets[0].Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,
15 "CONFIDENTIAL", "Arial Black", 60, false, true
16 , 1, 8, 1, 1, 130, 500);
17 
18             //Get the fill format of the word art
19             MsoFillFormat wordArtFormat = wordart.FillFormat;
20 
21             //Set the color
22             wordArtFormat.ForeColor = System.Drawing.Color.Red;
23 
24             //Set the transparency
25             wordArtFormat.Transparency = 0.9;
26 
27             //Make the line invisible
28             MsoLineFormat lineFormat = wordart.LineFormat;
29             lineFormat.IsVisible = false;
30 
31             designer.Process();
32             //将流文件写到客户端流的形式写到客户端
33             designer.Save(fileName, SaveType.OpenInExcel, FileType, reponse);
34         }

 

posted on 2019-03-04 17:00  MichelleDawm  阅读(1338)  评论(0编辑  收藏  举报