Grafiğin Veri Etiketlerinin Metin Sarılmasını Devre Dışı Bırakma
Aspose.Cells, DataLabels.setTextWrapped() metodunu sağlar. Metin sarmalamayı etkinleştirmek veya devre dışı bırakmak için True veya False olarak ayarlayın.
Benzer şekilde, bir veri etiketinin zaten sarılı olup olmadığını bulmak için DataLabels.isTextWrapped() metodunu kullanın.
Bu ekran görüntüsü, Microsoft Excel 2013 içeren bir örnek Excel dosyasını gösterir, içinde veri etiketlerinin metni sarılmıştır. Görebileceğiniz gibi, Microsoft Excel 2013’ün Format Datalabels panelinin ALIGNMENT bölümünde Şeklin içinde metni sarma seçeneğini kontrol edip temizleyebilirsiniz.
Veri etiketlerini sarma
Aşağıdaki örnek kod, Aspose.Cells kullanarak örnek Microsoft Excel dosyasını yükler ve DataLabels.setTextWrapped() yöntemini kullanarak veri etiketi metin sarmasını devre dışı bırakır. Kod çalıştırıldığında, grafik şu şekilde görünecektir. Önceden sarmalanmış metin artık sarmalanmamıştır.
Veri etiketlerini yalnızca bir satırda gösterme
// 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(DisableTextWrapping.class); | |
// Load the sample Excel file inside the workbook object | |
Workbook workbook = new Workbook(dataDir + "SampleChart.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Access the first chart inside the worksheet | |
Chart chart = worksheet.getCharts().get(0); | |
// Disable the Text Wrapping of Data Labels in all Series | |
chart.getNSeries().get(0).getDataLabels().setTextWrapped(false); | |
chart.getNSeries().get(1).getDataLabels().setTextWrapped(false); | |
chart.getNSeries().get(2).getDataLabels().setTextWrapped(false); | |
// Save the workbook | |
workbook.save(dataDir + "Output.xlsx"); |