Aspose.Cell 生成带水印的excel文件

 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         }

 

转载于:https://www.cnblogs.com/michelledawm/p/10471731.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值