Excel’s Accounting Format: An Overview

I have attempted the solution. One approach is to set the cell style and modify the format attribute using a custom format, such as the one provided below. It might work, but I cannot guarantee it. The Accounting format is a distinct built-in number format that appears and functions similarly to the Currency format. However, unlike the Currency format, the Accounting format aligns the numbers in a column.


Question:

In my code, I aim to access the
generate Excel
document by leveraging

c#

through the use of the

NPOI XSSFWorkbook

class. When printing decimal values onto an Excel sheet, I plan to specify its
Accounting formatting
.

I am attempting to format my data to resemble

$35.00

using XSSFWorkbook, however, my attempts have been unsuccessful. I have already experimented with

CellStyle.DataFormat = _workbook.CreateDataFormat().GetFormat("#,##0");

.


Solution:

Initially, establish the format for your cell and subsequently modify its
FORMAT
property using personalized
Format
.

IDataFormat dataFormatCustom = workbook.CreateDataFormat();
cell.CellStyle = styles["cell"]; 
cell.CellStyle.DataFormat = dataFormatCustom.GetFormat("_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)");

I cannot confirm if this will be effective.

Frequently Asked Questions