Ajout de texte enrichi HTML à l'intérieur du Cell
Aspose.Cells prend en charge la conversion de Microsoft orienté Excel HTML au format XLS/XLSX. Cela signifie que le HTML généré par Microsoft Excel peut être reconverti au format XLS/XLSX en utilisant Aspose.Cells.
De même, s’il y a un simple HTML, Aspose.Cells peut le convertir en HTML Rich Text. Aspose.Cells fournitCell.setHtmlString() propriété qui peut prendre un HTML aussi simple et le convertir en texte de cellule formaté.
Exemple
La capture d’écran suivante montre le fichier Excel de sortie généré avec Aspose.Cells. Comme vous pouvez le voir, il montre HTML texte enrichi formaté ajouté à l’intérieur de la cellule A1 en utilisant leCell.setHtmlString()la propriété.
Il s’agit de l’exemple de code qui a généré le fichier Excel de sortie, comme indiqué dans la capture d’écran ci-dessus.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
String dataDir = Utils.getDataDir(AddImageHyperlinks.class); | |
// Instantiate a new workbook | |
Workbook workbook = new Workbook(); | |
// Get the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Insert a string value to a cell | |
worksheet.getCells().get("C2").setValue("Image Hyperlink"); | |
// Set the 4th row height | |
worksheet.getCells().setRowHeight(3, 100); | |
// Set the C column width | |
worksheet.getCells().setColumnWidth(2, 21); | |
// Add a picture to the C4 cell | |
int index = worksheet.getPictures().add(3, 2, 4, 3, dataDir + "aspose-logo.jpg"); | |
// Get the picture object | |
com.aspose.cells.Picture pic = worksheet.getPictures().get(index); | |
// Set the placement type | |
pic.setPlacement(PlacementType.FREE_FLOATING); | |
// Add an image hyperlink | |
pic.addHyperlink("http://www.aspose.com/"); | |
com.aspose.cells.Hyperlink hlink = pic.getHyperlink(); | |
// Specify the screen tip | |
hlink.setScreenTip("Click to go to Aspose site"); | |
// Save the Excel file | |
workbook.save(dataDir + "ImageHyperlink.xls"); |