Excel コメントに画像を追加する
Contents
[
Hide
]
Microsoft Excel では、ユーザーはスプレッドシートのルック アンド フィールを大幅にカスタマイズできます。コメントに背景画像を追加することもできます。
コメントをセルに追加して、数式の詳細、値の取得元、レビュー担当者からの質問など、コメントを記録します。背景画像を追加することは、審美的な選択である場合もあれば、ブランディングを強化するために使用する場合もあります。
Microsoft Excel で Excel コメントに画像を追加する
Microsoft Excel 2007 では、セル コメントの背景として画像を使用できます。 Excel 2007 では、これは次のように行われます (コメントが既に追加されていると仮定します)。
- コメントを含むセルを右クリックします。
- 選ぶコメントの表示/非表示コメントからテキストをクリアします。
- コメントの枠線をクリックして選択します。
- 選ぶフォーマット、 それからコメント.
- [色と線] タブで、矢印をクリックします。色.
- クリック塗りつぶし効果.
- [画像] タブで、画像を選択.
- 画像を見つけて選択する
- クリックわかった.
Aspose.Cells の Excel コメントに画像を追加
Aspose.Cells は、この貴重な機能を提供します。
以下のサンプル コードは、XLSX ファイルを最初から作成し、セル A1 に画像の背景を持つコメントを追加します。
コードを実行すると、A1 には背景画像付きのコメントが表示されます。
出力ファイル
サンプルコード
This file contains 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.getSharedDataDir(AddPicturetoExcelComment.class) + "articles/"; | |
// Instantiate a Workbook | |
Workbook workbook = new Workbook(); | |
// Get a reference of comments collection with the first sheet | |
CommentCollection comments = workbook.getWorksheets().get(0).getComments(); | |
// Add a comment to cell A1 | |
int commentIndex = comments.add(0, 0); | |
Comment comment = comments.get(commentIndex); | |
comment.setNote("First note."); | |
comment.getFont().setName("Times New Roman"); | |
// Load/Read an image into stream | |
String logo_url = dataDir + "school.jpg"; | |
// Creating the instance of the FileInputStream object to open the logo/picture in the stream | |
FileInputStream inFile = new FileInputStream(logo_url); | |
// Setting the logo/picture | |
byte[] picData = new byte[inFile.available()]; | |
inFile.read(picData); | |
// Set image data to the shape associated with the comment | |
comment.getCommentShape().getFill().setImageData(picData); | |
// Save the workbook | |
workbook.save(dataDir + "APToExcelComment_out.xlsx"); |