Add Data Bars in Excel using Java

Import JAR Dependency (2 Method)


Sample Code

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

//Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);

//Get the specific cell range
CellRange range = sheet.getCellRange("B2:B13");

//Add the condotional format of data bar to the cell range
IConditionalFormat format = range.getConditionalFormats().addCondition();
format.setFormatType( ConditionalFormatType.DataBar);

//Set color for the data bar
format.getDataBar().setBarColor( Color.GREEN);

//Save to file
workbook.saveToFile("ApplyDataBars.xlsx", ExcelVersion.Version2013);




Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

[Unity ECS] Batched operation on EntityManager

Use a Local Version of a Library in Go

Deploying EIP2535 Diamond Proxy Contracts on Conflux

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

Introduction to docker

WAX Technical How To #9

Setup Zoiper as a RingCentral Device

Daily Progress: The Dead Walk Again! Thanks to us!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

Apply or Remove Data Validation in Excel Using Java

Open-source SPL that can execute SQL without RDB


Git: Overview through Key Terminology