22
33import { APIResource } from '../resource' ;
44import { APIPromise } from '../api-promise' ;
5+ import { buildHeaders } from '../internal/headers' ;
56import { RequestOptions } from '../internal/request-options' ;
67import { path } from '../internal/utils/path' ;
78
89export class Workbooks extends APIResource {
10+ /**
11+ * Export a workbook as an .xlsx file. Cells can be updated before the workbook is
12+ * exported.
13+ */
14+ export ( id : string , body : WorkbookExportParams , options ?: RequestOptions ) : APIPromise < Response > {
15+ return this . _client . post ( path `/v1/workbooks/${ id } /export` , {
16+ body,
17+ ...options ,
18+ headers : buildHeaders ( [
19+ { Accept : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' } ,
20+ options ?. headers ,
21+ ] ) ,
22+ __binaryResponse : true ,
23+ } ) ;
24+ }
25+
926 /**
1027 * Read cell data or apply temporary changes.
1128 *
@@ -19,8 +36,13 @@ export class Workbooks extends APIResource {
1936 /**
2037 * Render a chart using workbook data
2138 */
22- renderChart ( id : string , body : WorkbookRenderChartParams , options ?: RequestOptions ) : APIPromise < unknown > {
23- return this . _client . post ( path `/v1/workbooks/${ id } /chart` , { body, ...options } ) ;
39+ renderChart ( id : string , body : WorkbookRenderChartParams , options ?: RequestOptions ) : APIPromise < Response > {
40+ return this . _client . post ( path `/v1/workbooks/${ id } /chart` , {
41+ body,
42+ ...options ,
43+ headers : buildHeaders ( [ { Accept : 'image/png' } , options ?. headers ] ) ,
44+ __binaryResponse : true ,
45+ } ) ;
2446 }
2547}
2648
@@ -371,7 +393,60 @@ export namespace WorkbookQueryResponse {
371393 }
372394}
373395
374- export type WorkbookRenderChartResponse = unknown ;
396+ export interface WorkbookExportParams {
397+ /**
398+ * Cells to update before exporting
399+ */
400+ apply ?: Array < WorkbookExportParams . Apply > | null ;
401+
402+ /**
403+ * Goal seek. Use this to calculate the required input value for a formula to
404+ * achieve a specified target result. This is particularly useful when the desired
405+ * outcome is known, but the corresponding input is not.
406+ */
407+ goalSeek ?: WorkbookExportParams . GoalSeek | null ;
408+ }
409+
410+ export namespace WorkbookExportParams {
411+ /**
412+ * Specifies a temporary change to a workbook cell, including the `target` cell
413+ * reference and the `value` to apply. The API has no state, and so any changes
414+ * made are cleared after each request.
415+ */
416+ export interface Apply {
417+ /**
418+ * A1-style reference for the cell to write to
419+ */
420+ target : string ;
421+
422+ /**
423+ * Value to write to the target cell
424+ */
425+ value : number | string | boolean | null ;
426+ }
427+
428+ /**
429+ * Goal seek. Use this to calculate the required input value for a formula to
430+ * achieve a specified target result. This is particularly useful when the desired
431+ * outcome is known, but the corresponding input is not.
432+ */
433+ export interface GoalSeek {
434+ /**
435+ * Reference for the cell that will contain the solution
436+ */
437+ controlCell : string ;
438+
439+ /**
440+ * Reference for the cell that contains the formula you want to resolve
441+ */
442+ targetCell : string ;
443+
444+ /**
445+ * The value you want the formula to return
446+ */
447+ targetValue : number ;
448+ }
449+ }
375450
376451export interface WorkbookQueryParams {
377452 /**
@@ -539,7 +614,7 @@ export namespace WorkbookRenderChartParams {
539614export declare namespace Workbooks {
540615 export {
541616 type WorkbookQueryResponse as WorkbookQueryResponse ,
542- type WorkbookRenderChartResponse as WorkbookRenderChartResponse ,
617+ type WorkbookExportParams as WorkbookExportParams ,
543618 type WorkbookQueryParams as WorkbookQueryParams ,
544619 type WorkbookRenderChartParams as WorkbookRenderChartParams ,
545620 } ;
0 commit comments