可以使用Aspose.Cells為試算表添加特殊的文字效果。例如,可以展開標題,修飾文本,並使文本符合預設形狀,或者是為試算表添加浮水印效果。
在下面的例子中將示範如何使用Aspose.Cells提供的簡單API為工作表添加浮水印效果。
範例程式碼:
C#
//Instantiate a new WorkbookWorkbook workbook = new Workbook();//Get the first default sheetWorksheet sheet = workbook.Worksheets[0];//Add WatermarkAspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,"CONFIDENTIAL", "Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800);//Get the fill format of the word artMsoFillFormat wordArtFormat = wordart.FillFormat;//Set the colorwordArtFormat.ForeColor = System.Drawing.Color.Red;//Set the transparencywordArtFormat.Transparency = 0.9;//Make the line invisibleMsoLineFormat lineFormat = wordart.LineFormat;lineFormat.IsVisible = false;//Save the fileworkbook.Save("e:\\test2\\Watermarkt_Test.xls");
[VB]
'Instantiate a new WorkbookDim workbook As New Workbook()'Get the first default sheetDim sheet As Worksheet = workbook.Worksheets(0)'Add WatermarkDim wordart As Aspose.Cells.Drawing.Shape = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1, "CONFIDENTIAL", "Arial Black", 50, False, True, 18, 8, 1, 1, 130, 800)'Get the fill format of the word artDim wordArtFormat As MsoFillFormat = wordart.FillFormat'Set the colorwordArtFormat.ForeColor = System.Drawing.Color.Red'Set the transparencywordArtFormat.Transparency = 0.9'Make the line invisibleDim lineFormat As MsoLineFormat = wordart.LineFormatlineFormat.IsVisible = False'Save the fileworkbook.Save("e:\test2\Watermarkt_Test.xls")