Custom currency formats

Hi,

I need to apply custom currency formats to the column with different currency symbols and different currency symbol position - left or right.

In MS Excel those formats are:

#,##0.00$_);[Red](#,##0.00$)
$#,##0.00_);[Red]($#,##0.00)
#,##0.00€_);[Red](#,##0.00€)
€#,##0.00_);[Red](€#,##0.00)

Please let me know how I can do it.

Thanks.

Hi,

I also need to be able to add custom decimal and date formats.

Custom decimal formats:

#,##0_);[Red](#,##0)
#,##0.0_);[Red](#,##0.0)
#,##0.00_);[Red](#,##0.00)
#,##0.000_);[Red](#,##0.000)
#,##0.0000_);[Red](#,##0.0000)

Custom Date formats:

mm/dd/yy
dd/mm/yy
mm-dd-yy
dd-mm-yy
dd.mm.yy

Hi,

Thanks for considering Aspose.

Please consult the following example for your need:

Workbook workbook = new Workbook();

Cell cell = workbook.Worksheets[0].Cells["A1"];

cell.PutValue(3435.4376);

// Custom Currency format 1.

cell.Style.Custom = "#,##0.00$_);[Red](#,##0.00$)";

workbook.CalculateFormula();

MessageBox.Show(cell.StringValue);

cell = workbook.Worksheets[0].Cells["A2"];

cell.PutValue(3435.4376);

// Custom Currency format 2.

cell.Style.Custom = "€#,##0.00_);[Red](€#,##0.00)";

workbook.CalculateFormula();

MessageBox.Show(cell.StringValue);

cell = workbook.Worksheets[0].Cells["A3"];

cell.PutValue(3435.4376);

// Custom Decimal format 1.

cell.Style.Custom = "#,##0_);[Red](#,##0)";

workbook.CalculateFormula();

MessageBox.Show(cell.StringValue);

cell = workbook.Worksheets[0].Cells["A4"];

cell.PutValue(3435.4376);

// Custom Decimal format 4.

cell.Style.Custom = "#,##0.000_);[Red](#,##0.000)";

workbook.CalculateFormula();

MessageBox.Show(cell.StringValue);

cell = workbook.Worksheets[0].Cells["A5"];

cell.PutValue(DateTime.Now);

// Custom Date format 1.

cell.Style.Custom = "mm/dd/yy";

workbook.CalculateFormula();

MessageBox.Show(cell.StringValue);

cell = workbook.Worksheets[0].Cells["A6"];

cell.PutValue(DateTime.Now);

// Custom Date format 5.

cell.Style.Custom = "dd.mm.yy";

workbook.CalculateFormula();

MessageBox.Show(cell.StringValue);

workbook.Worksheets[0].AutoFitColumn(0);

workbook.Save("d:\\test\\testcustomformat.xls");

Thank you.