Ada Göre Metin Kutusuna Eriş
Contents
[
Hide
]
Daha önce, metin kutuları Workheet.getTextBoxes() koleksiyonundan dizinle erişiliyordu, ancak şimdi aynı koleksiyondan ismine göre de metin kutusuna erişebilirsiniz. Bu, metin kutusuna zaten ismini bildiğinizde erişmek için uygun ve hızlı bir yoldur.
İsme göre Metin Kutusuna Eriş
Aşağıdaki örnek kod öncelikle bir metin kutusu oluşturur ve ona bazı metin ve ad atar. Ardından aynı metin kutusuna adıyla erişir ve metnini yazdırır.
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.getDataDir(AccessTextBoxName.class); | |
Workbook workbook = new Workbook(); | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
int idx = sheet.getTextBoxes().add(10, 10, 10, 10); | |
// Create a texbox with some text and assign it some name | |
TextBox tb1 = sheet.getTextBoxes().get(idx); | |
tb1.setName("MyTextBox"); | |
tb1.setText("This is MyTextBox"); | |
// Access the same textbox via its name | |
TextBox tb2 = sheet.getTextBoxes().get("MyTextBox"); | |
// Displaying the text of the textbox accessed by its name | |
System.out.println(tb2.getText()); |
Konsol Çıktısı
Yukarıdaki örnek kodun konsol çıktısı burada gösterilmektedir.
This is MyTextBox