原創(chuàng)|其它|編輯:郝浩|2012-09-04 15:01:33.000|閱讀 1075 次
概述:大家都知道,水印是電子表格中比較常見的應(yīng)用。所以,強大的Aspose.Cells自然也有添加水印的功能啦,那么,這一功能具體是如何實現(xiàn)的呢?
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
大家都知道,水印是電子表格中比較常見的應(yīng)用。所以,強大的Aspose.Cells自然也有添加水印的功能啦,那么,這一功能具體是如何實現(xiàn)的呢?
下面,就由慧都小編給出一個實例,供大家學(xué)習(xí)使用:
本例中,我們的目的就是為Excel文件中的一個圖表添加藝術(shù)字背景水印。
首先,讓我們來看一下添加水印前的效果圖:
接下來,我們輸入相應(yīng)的代碼:
[C#]
//Instantiate a new workbook.
//Open the existing excel file.
Workbook workbook = new Workbook("e:\\test\
\Report_Test1.xls");
//Get the chart in the first worksheet.
Aspose.Cells.Charts.Chart chart = workbook.Worksheets
[0].Charts[0];
//Add a WordArt watermark (shape) to the chart's plot area.
Aspose.Cells.Drawing.Shape wordart =
chart.Shapes.AddTextEffectInChart
(MsoPresetTextEffect.TextEffect2,
"CONFIDENTIAL", "Arial Black", 66, false, false, 1200, 500,
2000, 3000);
//Get the shape's fill format.
Aspose.Cells.Drawing.MsoFillFormat wordArtFormat =
wordart.FillFormat;
//Set the transparency.
wordArtFormat.Transparency = 0.9;
//Get the line format and make it invisible.
Aspose.Cells.Drawing.MsoLineFormat lineFormat =
wordart.LineFormat;
lineFormat.IsVisible = false;
//Save the excel file.
workbook.Save("e:\\test\\outReport_Test1.xls");
[VB]
'Instantiate a new workbook.
'Open the existing excel file.
Dim workbook As New Workbook("e:\test\Report_Test1.xls")
'Get the chart in the first worksheet.
Dim chart As Aspose.Cells.Charts.Chart =
workbook.Worksheets(0).Charts(0)
'Add a WordArt watermark (shape) to the chart's plot area.
Dim wordart As Aspose.Cells.Drawing.Shape =
chart.Shapes.AddTextEffectInChart
(MsoPresetTextEffect.TextEffect2, "CONFIDENTIAL", "Arial
Black", 66, False, False, 1200, 500, 2000, 3000)
'Get the shape's fill format.
Dim wordArtFormat As Aspose.Cells.Drawing.MsoFillFormat =
wordart.FillFormat
'Set the transparency.
wordArtFormat.Transparency = 0.9
'Get the line format and make it invisible.
Dim lineFormat As Aspose.Cells.Drawing.MsoLineFormat =
wordart.LineFormat
lineFormat.IsVisible = False
'Save the excel file.
workbook.Save("e:\test\outReport_Test1.xls")
最后,讓我們來看一下代碼運行后的效果圖吧:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:本站原創(chuàng)