ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2015-09-16 10:28:39

toto_fr_2001
Member
Registered: 2015-09-11
Posts: 7

Get Data Format and compare

I can setup the range format using SetRangeDataFormat(...), see below (1)

Question: How can I get the rangeFormat (or Cell format) and compare it to a predefined format, see below (2)?

Thanks a lot
And, again, very impressive control
Damien


-------------------------------------

1. Setup the format
grid.CurrentWorksheet.SetRangeDataFormat(grid.CurrentWorksheet.SelectionRange, CellDataFormatFlag.Number, getFormatNumber());
private NumberDataFormatter.NumberFormatArgs getFormatNumber()
{
       return new NumberDataFormatter.NumberFormatArgs()
       {
            NegativeStyle = NumberDataFormatter.NumberNegativeStyle.Minus,
            UseSeparator = false,
        };
}
-------------------------------------
2. I would like to have something like:

if( Cell.GetDataFormat() == MyFormat())
    .......
with MyFormat() is defined in getFormatNumber() + CellDataFormatFlag.Number

So
1. How to construct MyFormat()
2. How to get the format from a cell (not the full style)

Offline

#2 2015-09-20 12:31:54

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Get Data Format and compare

For retrieving the cell data format and format arguments, you could access via the instance of cell:

using unvell.ReoGrid;
using unvell.ReoGrid.DataFormat;

...

var sheet = grid.CurrentWorksheet;

var cell = sheet.Cells["A1"];

if (cell.DataFormat == CellDataFormatFlag.Percent)
{
  var fmtArg = (NumberDataFormatter)cell.DataFormatArgs;
  // ...
}

In addition, if you want to create a customize data format, please refer to here: https://reogrid.net/document/custom-data-formatter/

Regards, Jing

Last edited by Jingwood (2015-09-20 12:34:19)

Offline

Board footer

Powered by FluxBB