# GC.Spread.Formatter.GeneralFormatter

## Content

# Class: GeneralFormatter

[Spread](../modules/GC.Spread).[Formatter](../modules/GC.Spread.Formatter).GeneralFormatter

## Table of contents

### Constructors

- [constructor](GC.Spread.Formatter.GeneralFormatter#constructor)

### Methods

- [format](GC.Spread.Formatter.GeneralFormatter#format)
- [formatString](GC.Spread.Formatter.GeneralFormatter#formatstring)
- [parse](GC.Spread.Formatter.GeneralFormatter#parse)

## Constructors

### <a id="constructor" name="constructor"></a> constructor

• **new GeneralFormatter**(`format?`, `cultureName?`)

Represents a formatter with the specified format mode and format string.

#### Parameters

| Name | Type |
| :------ | :------ |
| `format?` | `string` |
| `cultureName?` | `string` |

## Methods

### <a id="format" name="format"></a> format

▸ **format**(`obj`, `formattedData?`): `string`

Formats the specified object as a string with a formatted data Object.

**`example`**
```javascript
//This example uses the format method.
var formatter = new GC.Spread.Formatter.GeneralFormatter("#,##0.00");
var result = formatter.format(123456.789);
console.log(result); // '123,456.79'
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `obj` | `Object` | The object with cell data to format. |
| `formattedData?` | `Object` | - |

#### Returns

`string`

The formatted string.

___

### <a id="formatstring" name="formatstring"></a> formatString

▸ **formatString**(`value?`): `string` \| [`GeneralFormatter`](GC.Spread.Formatter.GeneralFormatter)

Gets or sets the format string for this formatter.

**`example`**
```javascript
//This example gets the format string.
var formatter = new GC.Spread.Formatter.GeneralFormatter("#,##0.00");
var result = formatter.formatString();
console.log(result); // '#,##0.00'
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value?` | `string` | The format string for this formatter. |

#### Returns

`string` \| [`GeneralFormatter`](GC.Spread.Formatter.GeneralFormatter)

If no value is set, returns the formatter string for this formatter; otherwise, returns the formatter.

___

### <a id="parse" name="parse"></a> parse

▸ **parse**(`str`): `Object`

Parses the specified text.

**`example`**
```javascript
//This example uses the parse method.
var formatter = new GC.Spread.Formatter.GeneralFormatter("#,##0.00");
var result = formatter.parse("123,456.78");
console.log(result); // 123456.78
```

#### Parameters

| Name | Type |
| :------ | :------ |
| `str` | `string` |

#### Returns

`Object`

The parsed object.
