@@ -33,6 +33,20 @@ export class Workbooks extends APIResource {
3333 } ) ;
3434 }
3535
36+ /**
37+ * Run calculations in a workbook and retrieve cell objects.
38+ *
39+ * @example
40+ * ```ts
41+ * const response = await client.workbooks.calc('id', {
42+ * read: ['A1'],
43+ * });
44+ * ```
45+ */
46+ calc ( id : string , body : WorkbookCalcParams , options ?: RequestOptions ) : APIPromise < WorkbookCalcResponse > {
47+ return this . _client . post ( path `/v1/workbooks/${ id } /calc` , { body, ...options } ) ;
48+ }
49+
3650 /**
3751 * Export a workbook as an .xlsx file. Cells can be updated before the workbook is
3852 * exported.
@@ -115,6 +129,24 @@ export class Workbooks extends APIResource {
115129 multipartFormRequestOptions ( { body, ...options } , this . _client ) ,
116130 ) ;
117131 }
132+
133+ /**
134+ * Run calculations in a workbook and retrieve cell values.
135+ *
136+ * @example
137+ * ```ts
138+ * const response = await client.workbooks.values('id', {
139+ * read: ['A1'],
140+ * });
141+ * ```
142+ */
143+ values (
144+ id : string ,
145+ body : WorkbookValuesParams ,
146+ options ?: RequestOptions ,
147+ ) : APIPromise < WorkbookValuesResponse > {
148+ return this . _client . post ( path `/v1/workbooks/${ id } /values` , { body, ...options } ) ;
149+ }
118150}
119151
120152export type WorkbookListResponsesCursorPagination = CursorPagination < WorkbookListResponse > ;
@@ -168,6 +200,66 @@ export interface WorkbookListResponse {
168200 latest_ready_version ?: number | null ;
169201}
170202
203+ /**
204+ * Response type returned by the for /calc query endpoint.
205+ */
206+ export type WorkbookCalcResponse = Record <
207+ string ,
208+ WorkbookCalcResponse . ReadValue | Array < WorkbookCalcResponse . UnionMember1 >
209+ > ;
210+
211+ export namespace WorkbookCalcResponse {
212+ export interface ReadValue {
213+ /**
214+ * Formatted cell value
215+ */
216+ formatted : string ;
217+
218+ /**
219+ * Cell position in the spreadsheet, using 0-indexed x/y coordinates. Origin [0, 0]
220+ * is at the top-left
221+ */
222+ offset : Array < unknown > ;
223+
224+ /**
225+ * Type of the cell value
226+ */
227+ type : 'blank' | 'boolean' | 'number' | 'string' | 'date' | 'error' ;
228+
229+ /**
230+ * Cell value
231+ */
232+ value : number | string | boolean | null ;
233+
234+ error ?: string | null ;
235+ }
236+
237+ export interface UnionMember1 {
238+ /**
239+ * Formatted cell value
240+ */
241+ formatted : string ;
242+
243+ /**
244+ * Cell position in the spreadsheet, using 0-indexed x/y coordinates. Origin [0, 0]
245+ * is at the top-left
246+ */
247+ offset : Array < unknown > ;
248+
249+ /**
250+ * Type of the cell value
251+ */
252+ type : 'blank' | 'boolean' | 'number' | 'string' | 'date' | 'error' ;
253+
254+ /**
255+ * Cell value
256+ */
257+ value : number | string | boolean | null ;
258+
259+ error ?: string | null ;
260+ }
261+ }
262+
171263/**
172264 * Contains the results of a workbook query, including `read` (queried cell data)
173265 * and `apply` (details of temporary changes applied). Note that the API has no
@@ -339,8 +431,22 @@ export interface WorkbookUploadResponse {
339431 id : string ;
340432}
341433
434+ /**
435+ * Response type returned by the for /values query endpoint.
436+ */
437+ export type WorkbookValuesResponse = Record <
438+ string ,
439+ number | string | boolean | Array < number | string | boolean | null > | null
440+ > ;
441+
342442export interface WorkbookListParams extends CursorPaginationParams { }
343443
444+ export interface WorkbookCalcParams {
445+ read : Array < string > ;
446+
447+ apply ?: Record < string , number | string | boolean | null > | null ;
448+ }
449+
344450export interface WorkbookExportParams {
345451 /**
346452 * Cells to update before exporting
@@ -833,16 +939,26 @@ export interface WorkbookUploadParams {
833939 file : Uploadable ;
834940}
835941
942+ export interface WorkbookValuesParams {
943+ read : Array < string > ;
944+
945+ apply ?: Record < string , number | string | boolean | null > | null ;
946+ }
947+
836948export declare namespace Workbooks {
837949 export {
838950 type WorkbookListResponse as WorkbookListResponse ,
951+ type WorkbookCalcResponse as WorkbookCalcResponse ,
839952 type WorkbookQueryResponse as WorkbookQueryResponse ,
840953 type WorkbookUploadResponse as WorkbookUploadResponse ,
954+ type WorkbookValuesResponse as WorkbookValuesResponse ,
841955 type WorkbookListResponsesCursorPagination as WorkbookListResponsesCursorPagination ,
842956 type WorkbookListParams as WorkbookListParams ,
957+ type WorkbookCalcParams as WorkbookCalcParams ,
843958 type WorkbookExportParams as WorkbookExportParams ,
844959 type WorkbookQueryParams as WorkbookQueryParams ,
845960 type WorkbookRenderChartParams as WorkbookRenderChartParams ,
846961 type WorkbookUploadParams as WorkbookUploadParams ,
962+ type WorkbookValuesParams as WorkbookValuesParams ,
847963 } ;
848964}
0 commit comments