原創(chuàng)|使用教程|編輯:張瑩心|2021-10-29 13:49:28.290|閱讀 606 次
概述:數(shù)據(jù)條是Microsoft Excel 提供的一種條件格式,用于可視化 Excel 單元格中的值。它們可以幫助您快速比較值,因?yàn)闂l形較長的單元格表示較大的值,而條形較短的單元格表示較小的值。本文將介紹如何使用Spire.XLS for Java在一系列單元格中添加數(shù)據(jù)條。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Spire.XLS for Java是專業(yè)的Java Excel API,使開發(fā)人員無需使用Microsoft Office或Microsoft Excel即可創(chuàng)建,管理,操作,轉(zhuǎn)換和打印Excel工作表。
*這么優(yōu)秀的國產(chǎn)工具怎能錯(cuò)過呢!在線下單專享“一口價(jià)”,立即購買!想要獲取更多福利的朋友可以哦~
數(shù)據(jù)條是Microsoft Excel 提供的一種條件格式,用于可視化 Excel 單元格中的值。它們可以幫助您快速比較值,因?yàn)闂l形較長的單元格表示較大的值,而條形較短的單元格表示較小的值。本文將介紹如何使用Spire.XLS for Java在一系列單元格中添加數(shù)據(jù)條。
在 Excel 中添加數(shù)據(jù)欄
以下是通過條件格式在一系列 Excel 單元格中添加數(shù)據(jù)欄的步驟:
import com.spire.xls.*; import com.spire.xls.core.*; import java.awt.*; public class applyDataBars { public static void main(String[] args) { //Create a Workbook instance Workbook workbook = new Workbook(); //Load an Excel file workbook.loadFromFile("C:\\Users\\Administrator\\Desktop\\test.xlsx"); //Get the first worksheet. Worksheet sheet = workbook.getWorksheets().get(0); //Get the specific cell range CellRange range = sheet.getCellRange("B2:B13"); //Add the conditional formatting of data bars in the cell range IConditionalFormat format = range.getConditionalFormats().addCondition(); format.setFormatType( ConditionalFormatType.DataBar); //Set color for the data bars format.getDataBar().setBarColor( Color.GREEN); //Save to file workbook.saveToFile("ApplyDataBars.xlsx", ExcelVersion.Version2013); } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn