# Auto Fill Strings

A tutorial showing how to auto fill strings in SpreadJS

## Content

SpreadJS can fill string values by copying the selected values or by generating a string series. A string series is generated when SpreadJS detects a numeric part in the source value and increments that numeric part during the fill operation.
For example, SpreadJS can fill strings that contain only numbers, strings with a number at the end, and strings with a number at the beginning. If the selected values do not form a supported series pattern, SpreadJS copies the values in the same order.
![SpreadJS worksheet string drag fill workflow showing cell values with numeric parts generating an incremented string series in a filled cell range.](https://cdn.mescius.io/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/images/string-1-dragfill.gif?width=400)
Strings that contain numbers at the beginning and strings that do not form a numeric series can also be filled based on the detected pattern.
![SpreadJS worksheet showing string drag fill behavior where detected numeric prefix patterns are filled as a series or copied when unsupported.](https://cdn.mescius.io/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/images/string-2-dragfill.gif?width=400)

## String Series Behavior

When filling a string series, SpreadJS detects numeric parts in the source values. A numeric part can contain half-width digits (`0` to `9`), full-width digits (`０` to `９`), or a supported mix of both.
The following table shows common string series patterns.

| Source value | Filled values | Description |
| ------------ | ------------- | ----------- |
| `123` | `124`, `125`, `126` | A number-only string is incremented as a numeric series. |
| `Item1` | `Item2`, `Item3`, `Item4` | A numeric suffix is incremented. |
| `1Q` | `2Q`, `3Q`, `4Q` | A numeric prefix is incremented. |
| `１２３` | `１２４`, `１２５`, `１２６` | Full-width digits are recognized as numeric digits. |
| `a１2` | `a１3`, `a１4` | Mixed full-width and half-width digits in one numeric token are parsed as one number. |
| `A1A1`, `A2A2` | `A1A1`, `A2A2`, `A1A1`, `A2A2` | Values that do not form a supported series pattern are copied in order. |

![SpreadJS worksheet demonstrating string series behavior where the fillAuto-style drag fill operation increments supported numeric tokens and copies unsupported patterns.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/string-20260706.cc79f4.gif?width=400)
When a single string value is copied after drag fill, users can open the fill options menu and select **Fill Series** to generate a series.
![SpreadJS worksheet workflow showing a copied single string value changed into an incremented series by selecting the Fill Series command from the fill options menu.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/fillSeries-20260706.a4e302.gif?width=400)

### Full-Width Digits in String Series

String series can include full-width decimal digits (`０` to `９`). During series detection, SpreadJS treats full-width digits as numeric digits, equivalent to half-width digits (`0` to `9`).
This recognition is always enabled and is not limited to CJK cultures. Full-width and half-width digits can also be mixed within the same numeric token. SpreadJS parses the combined token as one number and preserves the digit-width pattern from the source value when generating the filled values.
The following table shows examples of string series that include full-width digits.

| Source value | Filled values | Description |
| ------------ | ------------- | ----------- |
| `１２３` | `１２４`, `１２５`, `１２６` | A number-only string with full-width digits is incremented as a numeric series. |
| `a１` | `a２`, `a３`, `a４` | A full-width numeric suffix is incremented. |
| `１a` | `２a`, `３a`, `４a` | A full-width numeric prefix is incremented. |
| `a１2` | `a１3`, `a１4` | Mixed full-width and half-width digits in one numeric token are parsed as one number. |
| `a１`, `a３` | `a５`, `a７`, `a９` | Arithmetic step detection works with full-width digits. |
| `a１`, `b１` | `a１`, `b１`, `a１`, `b１` | Values with different text prefixes are copied instead of incremented. |

![SpreadJS worksheet showing string series drag fill with full-width and mixed-width numeric digits recognized as numeric tokens in the filled cell range.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/fullWidth-20260706.7751af.gif?width=400)
Culture-specific string patterns, such as CJK text-number-text patterns and linker patterns, still depend on the active culture.

>type=note
> **Note:** In the default English culture, string series that contain full-width digits may produce results that are different from Excel.

## Using Code

You can also fill a string series programmatically by using the [`fillAuto`](/spreadjs/api/v19/classes/GC.Spread.Sheets.Worksheet#fillauto) method.
The following code sample fills a string series that contains full-width digits.

```javascript
const sheet = spread.getActiveSheet();

sheet.setValue(0, 0, "a１");

sheet.fillAuto(
    new GC.Spread.Sheets.Range(0, 0, 1, 1),
    new GC.Spread.Sheets.Range(0, 0, 4, 1),
    {
        fillType: GC.Spread.Sheets.Fill.FillType.auto,
        series: GC.Spread.Sheets.Fill.FillSeries.column,
        fillDirection: GC.Spread.Sheets.Fill.FillDirection.down
    }
);

// Result:
// a１
// a２
// a３
// a４
```