[]
        
(Showing Draft Content)

Auto Fill Strings

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.

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.

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.

123

124, 125, 126

Full-width digits are recognized as numeric digits.

a12

a13, a14

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.

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.

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

123

124, 125, 126

A number-only string with full-width digits is incremented as a numeric series.

a1

a2, a3, a4

A full-width numeric suffix is incremented.

1a

2a, 3a, 4a

A full-width numeric prefix is incremented.

a12

a13, a14

Mixed full-width and half-width digits in one numeric token are parsed as one number.

a1, a3

a5, a7, a9

Arithmetic step detection works with full-width digits.

a1, b1

a1, b1, a1, b1

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.

Culture-specific string patterns, such as CJK text-number-text patterns and linker patterns, still depend on the active culture.

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 method.

The following code sample fills a string series that contains full-width digits.

const sheet = spread.getActiveSheet();

sheet.setValue(0, 0, "a1");

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:
// a1
// a2
// a3
// a4