{"id":6502,"date":"2021-06-24T11:19:00","date_gmt":"2021-06-24T18:19:00","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=6502"},"modified":"2022-05-31T09:10:17","modified_gmt":"2022-05-31T16:10:17","slug":"analysis-cloud-limited-automates-excel-reporting-modernizes-workflow-using-office-scripts","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/analysis-cloud-limited-automates-excel-reporting-modernizes-workflow-using-office-scripts\/","title":{"rendered":"Office Scripts help Analysis Cloud Limited automate and modernize workflow"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-6503\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/LeslieBlack-150x150.png\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/LeslieBlack-150x150.png 150w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/LeslieBlack-24x24.png 24w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/LeslieBlack-48x48.png 48w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/LeslieBlack-96x96.png 96w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/LeslieBlack-300x300.png 300w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/p>\n<p>Learn how Office Scripts in Excel helped Analysis Cloud Limited modernize their workflow with Leslie Black, Developer, Analysis Cloud Limited.<\/p>\n<h2>Office Scripts reduce an arduous process to a simple action<\/h2>\n<p><span data-contrast=\"none\">At Analysis Cloud Limited, we used Office Scripts in Excel to completely automate a Covid-19 reporting process used by one of our clients. Using scripts, we reduced the process to a simple action. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Before using Office Scripts, our client needed to extend chart ranges and add new data points by hand, gather data from contributor\u2019s emails, and even manually find pictures of charts from\u00a0<\/span><span data-contrast=\"none\">third-party websites, as well as gather data from contributor\u2019s emails and enter them manually into a workbook. Now they can just feed their daily data into Lists and Teams and Power Automate sends this data to a script that creates their report. Our script also automatically updates a Power BI report, creates a daily PDF, and creates backups to Azure Blob Storage. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Using scripts was a huge change in productivity for our client. The process of updating their Covid report took one employee all day, every day to manage \u2013 and is now a completely automated activity, freeing up time and energy for our clients to do more with their day! <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h3>A learning opportunity for our business<\/h3>\n<p><span data-contrast=\"none\">Additionally, this was a great learning opportunity for our business. Previously we have helped many clients using VBA. In this case, we were able to replicate what we might have done with VBA and brought the extra benefit of relocating Excel workbooks to the cloud. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Interested in how we did this? Check out this Office Scripts sample similar to part of our code: <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true\">function main(workbook: ExcelScript.Workbook) { \r\n\r\n  let sheet = workbook.getWorksheets()[0] \r\n\r\n  let table2 = workbook.getTable(\"Table2\") \r\n\r\n  \/\/ Delete 1 row(s) at index 0 from table Table2 \r\n\r\n  let Table2RowCount = table2.getRowCount() \r\n\r\n  if(Table2RowCount==0){ \r\n\r\n    console.log('Table2RowCount: ' +Table2RowCount) \r\n\r\n  }else{ \r\n\r\n    console.log(Table2RowCount +' rows deleted.') \r\n\r\n    table2.deleteRowsAt(0, Table2RowCount); \/\/deletes Table2RowCount (x) rows \r\n\r\n  } \r\n\r\n  \/\/delete last column \r\n\r\n  let tableRangeCC = table2.getRange() \r\n\r\n  let tableRangeCCAddress = tableRangeCC.getAddress() \r\n\r\n  console.log(tableRangeCC.getAddress())  \/\/Sheet1!C4:F5 \r\n\r\n  \/\/obtain value of F4 \r\n\r\n  let searchColon = tableRangeCCAddress.search(\":\") \r\n\r\n  let firstRow = tableRangeCCAddress.substring(searchColon - 1,searchColon) \r\n\r\n  let lastCol = tableRangeCCAddress.substring(searchColon +1, searchColon+2) \r\n\r\n  let lastHeaderVal = sheet.getRange(lastCol + firstRow).getValue().toString() \r\n\r\n  \r\n\r\n  console.log('lastColName: ' +lastHeaderVal) \/\/\/\/ \r\n\r\n  if(lastHeaderVal =='Week'){ \r\n\r\n    table2.getColumns()[3].delete() \r\n\r\n    console.log('Column ' + lastHeaderVal + ' was deleted.')<\/pre>\n<h3>Resources<\/h3>\n<p><span class=\"TextRun SCXW107732381 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW107732381 BCX8\"><a href=\"https:\/\/docs.microsoft.com\/office\/dev\/scripts\/tutorials\/excel-tutorial\">Record, edit, and create Office Scripts in Excel on the web<\/a><\/span><\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/category\/office-scripts\/\">Microsoft 365 developer blog<\/a><\/p>\n<p><a href=\"https:\/\/developer.microsoft.com\/office-scripts\">Office Scripts Developer Center<\/a><\/p>\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At Analysis Cloud Limited, we\u2019ve used Office Scripts to completely automate a Covid-19 reporting process used by one of our clients. Using Office Scripts meant that an arduous process was reduced to a simple action.  <\/p>\n","protected":false},"author":69076,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11],"tags":[18,177],"class_list":["post-6502","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office-add-ins","tag-excel","tag-office-scripts"],"acf":[],"blog_post_summary":"<p>At Analysis Cloud Limited, we\u2019ve used Office Scripts to completely automate a Covid-19 reporting process used by one of our clients. Using Office Scripts meant that an arduous process was reduced to a simple action.  <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/6502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69076"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=6502"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/6502\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=6502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=6502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=6502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}