@@ -9,7 +9,7 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
99 description : 'Read, write, and update data' ,
1010 authMode : AuthMode . OAuth ,
1111 longDescription :
12- 'Integrate Microsoft Excel into the workflow. Can read, write, update, and add to table.' ,
12+ 'Integrate Microsoft Excel into the workflow. Can read, write, update, add to table, and create new worksheets .' ,
1313 docsLink : 'https://docs.sim.ai/tools/microsoft_excel' ,
1414 category : 'tools' ,
1515 bgColor : '#E0E0E0' ,
@@ -23,6 +23,7 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
2323 { label : 'Read Data' , id : 'read' } ,
2424 { label : 'Write/Update Data' , id : 'write' } ,
2525 { label : 'Add to Table' , id : 'table_add' } ,
26+ { label : 'Add Worksheet' , id : 'worksheet_add' } ,
2627 ] ,
2728 value : ( ) => 'read' ,
2829 } ,
@@ -80,6 +81,14 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
8081 condition : { field : 'operation' , value : [ 'table_add' ] } ,
8182 required : true ,
8283 } ,
84+ {
85+ id : 'worksheetName' ,
86+ title : 'Worksheet Name' ,
87+ type : 'short-input' ,
88+ placeholder : 'Name of the new worksheet (max 31 characters)' ,
89+ condition : { field : 'operation' , value : [ 'worksheet_add' ] } ,
90+ required : true ,
91+ } ,
8392 {
8493 id : 'values' ,
8594 title : 'Values' ,
@@ -129,7 +138,12 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
129138 } ,
130139 ] ,
131140 tools : {
132- access : [ 'microsoft_excel_read' , 'microsoft_excel_write' , 'microsoft_excel_table_add' ] ,
141+ access : [
142+ 'microsoft_excel_read' ,
143+ 'microsoft_excel_write' ,
144+ 'microsoft_excel_table_add' ,
145+ 'microsoft_excel_worksheet_add' ,
146+ ] ,
133147 config : {
134148 tool : ( params ) => {
135149 switch ( params . operation ) {
@@ -139,13 +153,22 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
139153 return 'microsoft_excel_write'
140154 case 'table_add' :
141155 return 'microsoft_excel_table_add'
156+ case 'worksheet_add' :
157+ return 'microsoft_excel_worksheet_add'
142158 default :
143159 throw new Error ( `Invalid Microsoft Excel operation: ${ params . operation } ` )
144160 }
145161 } ,
146162 params : ( params ) => {
147- const { credential, values, spreadsheetId, manualSpreadsheetId, tableName, ...rest } =
148- params
163+ const {
164+ credential,
165+ values,
166+ spreadsheetId,
167+ manualSpreadsheetId,
168+ tableName,
169+ worksheetName,
170+ ...rest
171+ } = params
149172
150173 const effectiveSpreadsheetId = ( spreadsheetId || manualSpreadsheetId || '' ) . trim ( )
151174
@@ -164,6 +187,10 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
164187 throw new Error ( 'Table name is required for table operations.' )
165188 }
166189
190+ if ( params . operation === 'worksheet_add' && ! worksheetName ) {
191+ throw new Error ( 'Worksheet name is required for worksheet operations.' )
192+ }
193+
167194 const baseParams = {
168195 ...rest ,
169196 spreadsheetId : effectiveSpreadsheetId ,
@@ -178,6 +205,13 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
178205 }
179206 }
180207
208+ if ( params . operation === 'worksheet_add' ) {
209+ return {
210+ ...baseParams ,
211+ worksheetName,
212+ }
213+ }
214+
181215 return baseParams
182216 } ,
183217 } ,
@@ -189,6 +223,7 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
189223 manualSpreadsheetId : { type : 'string' , description : 'Manual spreadsheet identifier' } ,
190224 range : { type : 'string' , description : 'Cell range' } ,
191225 tableName : { type : 'string' , description : 'Table name' } ,
226+ worksheetName : { type : 'string' , description : 'Worksheet name' } ,
192227 values : { type : 'string' , description : 'Cell values data' } ,
193228 valueInputOption : { type : 'string' , description : 'Value input option' } ,
194229 } ,
@@ -207,5 +242,9 @@ export const MicrosoftExcelBlock: BlockConfig<MicrosoftExcelResponse> = {
207242 } ,
208243 index : { type : 'number' , description : 'Row index for table add operations' } ,
209244 values : { type : 'json' , description : 'Cell values array for table add operations' } ,
245+ worksheet : {
246+ type : 'json' ,
247+ description : 'Details of the newly created worksheet (worksheet_add operations)' ,
248+ } ,
210249 } ,
211250}
0 commit comments