使用 Aspose.Cells 在 Excel 工作簿中创建签名行
Contents
[
Hide
]
Microsoft Excel提供了一个添加功能签名行在 Excel 工作簿中。您可以通过单击插入选项卡然后选择签名行来自文本团体。
Aspose.Cells也提供了这个功能,并暴露了Picture.setSignatureLine()为此目的的财产。本文将解释如何使用此属性添加使用 Aspose.Cells 的签名行。
Java 使用 Aspose.Cells 在 Excel 工作簿中创建签名行的代码
以下示例代码使用Picture.setSignatureLine()属性并保存工作簿。屏幕截图显示了输出工作簿在 Microsoft Excel 中的样子。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CreateSignatureLine.class); | |
// Create workbook object | |
Workbook workbook = new Workbook(); | |
// Insert picture of your choice | |
int index = workbook.getWorksheets().get(0).getPictures().add(0, 0, "signature.jpg"); | |
// Access picture and add signature line inside it | |
Picture pic = workbook.getWorksheets().get(0).getPictures().get(index); | |
// Create signature line object | |
SignatureLine s = new SignatureLine(); | |
s.setSigner("Simon Zhao"); | |
s.setTitle("Development Lead"); | |
s.setEmail("Simon.Zhao@aspose.com"); | |
// Assign the signature line object to Picture.SignatureLine property | |
pic.setSignatureLine(s); | |
// Save the workbook | |
workbook.save(dataDir + "output.xlsx"); |