Posted 2 March 2026, 1:54 am EST
- Updated 2 March 2026, 2:27 am EST
When generating a view, I realized that the issue could be resolved by setting a style — one that specifies a certain cell type — on the column.
table.fetch().then(() => {
const cellType = new GC.Spread.Sheets.CellTypes.ComboBox();
const style = new GC.Spread.Sheets.Style();
style.cellType = cellType;
const view = table.addView(
'myView',
[
{ caption: 'Options', value: 'options', style: style as never },
]);
tableSheet.setDataView(view);
});
However, one question remains.
According to the contents of the gc.spread.sheets.d.ts file, the second argument of the addView method is of type GC.Data.IColumn, but the style property of IColumn is of type GC.Data.StyleOptions. Because of this, assigning a GC.Spread.Sheets.Style object to the style property results in a TypeScript syntax error: TS2322 (TS) Type ‘Style’ is not assignable to type ‘StyleOptions’.
addView(name: string, columnInfos?: string[] | GC.Data.IColumn[], includeDefaultColumns?: boolean, options?: GC.Data.ViewOptions): GC.Data.View;
export type IColumn =
{
/**
* The unique name of the column.
*/
name?: string;
/**
* The value of the column, could be a field name of table from database, or formula which uses the fields names.
*/
value?: string;
/**
* The column type, any of "Number", "Text", "Formula", "Checkbox", "Date", "Currency", "Percent", "Phone", "Email", "URL", "Lookup", "CreatedTime", "ModifiedTime", "Attachment", "Select", "Barcode"
*/
type?: string;
/**
* The caption of the column.
*/
caption?: string | string[];
/**
* The width of the column, support number in pixel, or star size.
*/
width?: number | string;
/**
* The style of the column.
*/
style?: GC.Data.StyleOptions;
/**
* The conditional formats array of the column.
*/
conditionalFormats?: Array<GC.Data.CellValueRuleOptions | GC.Data.SpecificTextRuleOptions | GC.Data.FormulaRuleOptions | GC.Data.DateOccurringRuleOptions | GC.Data.Top10RuleOptions | GC.Data.UniqueRuleOptions | GC.Data.DuplicateRuleOptions | GC.Data.AverageRuleOptions | GC.Data.TwoScaleRuleOptions | GC.Data.ThreeScaleRuleOptions | GC.Data.DataBarRuleOptions | GC.Data.IconSetRuleOptions>;
/**
* The data validator of the column.
*/
validator?: GC.Data.NumberValidatorOptions | GC.Data.DateValidatorOptions | GC.Data.TimeValidatorOptions | GC.Data.TextLengthValidatorOptions | GC.Data.FormulaValidatorOptions | GC.Data.FormulaListValidatorOptions | GC.Data.ListValidatorOptions;
/**
* Mark the column as primary key column.
*/
isPrimaryKey?: boolean;
/**
* Mark the column is readonly.
*/
readonly?: boolean;
/**
* Mark the column is required when insert a new row.
*/
required?: boolean;
/**
* Provide the default value when insert a new row, could be a const or a formula.
*/
defaultValue?: any;
/**
* The header style of the column.
*/
headerStyle?: GC.Data.HeaderStyleOptions;
/**
* Mark the column is visible.
*/
visible?: boolean;
/**
* The header fit mode, any of the "normal", "vertical" or "stack". The default value is "normal".
*/
headerFit?: "normal" | "vertical" | "stack";
/**
* The actual data type of original value, any of "string", "number", "boolean", "object", "formula", "array", "date" or "rowOrder". It is useful for a Date because a Date is a string in JSON data and need be converted.
*/
dataType?: "string" | "number" | "boolean" | "object" | "formula" | "array" | "date" | "rowOrder" | "TaskStartDate" | "TaskFinishDate" | "TaskDuration" | "TaskSubject" | "TaskSchedulingMode" | "TaskComplete" | "TaskPredecessor";
/**
* The data pattern for parsing string to value, such as formatter "dd/MM/yyyy" for a date string, truthy and falsy value pairs "Yes|No" for a boolean string, decimal separator "," for a numeric string.
*/
dataPattern?: string;
/**
* A simple map to display the original value more meaningful, its key could be a number or string, and its value could be a number, string or Date.
*/
dataMap?: any;
/**
* Whether to spread a column when its value is an object.
*/
spread?: boolean;
/**
* The original name of the table field, using this property to map the original name to the specified name.
*/
dataName?: string;
/**
* Weather need to create the filter cache while creating the table.
*/
indexed?: boolean;
/**
* Whether show sort after opening filer dialog.
*/
allowSort?: boolean;
/**
* Whether show filter by value after opening filer dialog.
*/
allowFilterByValue?: boolean;
/**
* Whether show filter by list after opening filer dialog. If allowSort, allowFilterByValue and allowFilterByList are all false, not show the filter button in this column.
*/
allowFilterByList?: boolean;
/**
* The cross options of the column.
*/
cross?: string | GC.Data.ICrossOptions;
/**
* Define the lookup for the column, only be used in the columns of the schema of the data source.
*/
lookup?: string | (string | number | boolean | Date)[] | GC.Data.ILookupOptions;
/**
* Define the outline column only when the data be the hierarchy data.
*/
outlineColumn?: boolean | GC.Data.IOutlineColumnOptions;
/**
* The trigger formula of the column.
*/
trigger?: GC.Data.ITriggerFormulaOption;
}