{"id":2057,"date":"2017-02-08T13:17:04","date_gmt":"2017-02-08T13:17:04","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=2057"},"modified":"2017-02-08T13:24:27","modified_gmt":"2017-02-08T13:24:27","slug":"groovy-writing-and-reading-from-excel","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/groovy-writing-and-reading-from-excel\/","title":{"rendered":"Groovy Writing and Reading from Excel"},"content":{"rendered":"<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage com.mugil.first\r\nimport jxl.*\r\nimport jxl.write.*\r\n\r\n\r\nclass ExcelUtils {\r\n\tpublic static void main(String&#x5B;] args)\r\n\t{\r\n\t\twriteExcel()\r\n\t\treadExcel()\r\n\t}\r\n\t\r\n\tstatic def writeExcel()\r\n\t{\r\n\t\tWritableWorkbook workbook = Workbook.createWorkbook(new File(&quot;d:\\\\output.xls&quot;))\r\n\t\tWritableSheet sheet = workbook.createSheet(&quot;Worksheet1&quot;, 0)\t\t \r\n\t\t\r\n\t\tfor(int i=0;i&lt;3;i++)\r\n\t\t{\r\n\t\t\tfor(int j=0;j&lt;5;j++)\r\n\t\t\t{\r\n\t\t\t\tLabel label = new Label(i, j, i+&quot;,&quot;+j);\r\n\t\t\t\tsheet.addCell(label);\r\n\t\t\t}\r\n\t\t}\t\t\r\n\t\t\r\n\t\tworkbook.write()\r\n\t\tworkbook.close()\t\r\n\t\t\r\n\t}\r\n\t\r\n\tstatic def readExcel()\r\n\t{\r\n\t\tWorkbook workbook1 = Workbook.getWorkbook(new File(&quot;d:\\\\output.xls&quot;))\r\n\t\tSheet sheet1 = workbook1.getSheet(0)\r\n\t\tCell a1 = sheet1.getCell(0,2) \r\n\t\tCell b2 = sheet1.getCell(2,2) \r\n\t\tCell c2 = sheet1.getCell(2,1)\r\n\t\t\r\n\t\tprintln a1.getContents();\r\n\t\tprintln b2.getContents();\r\n\t\tprintln c2.getContents();\t\t\r\n\t\t\r\n\t\tworkbook1.close()\r\n\t}\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>package com.mugil.first import jxl.* import jxl.write.* class ExcelUtils { public static void main(String&#x5B;] args) { writeExcel() readExcel() } static def writeExcel() { WritableWorkbook workbook = Workbook.createWorkbook(new File(&quot;d:\\\\output.xls&quot;)) WritableSheet sheet = workbook.createSheet(&quot;Worksheet1&quot;, 0) for(int i=0;i&lt;3;i++) { for(int j=0;j&lt;5;j++) { Label label = new Label(i, j, i+&quot;,&quot;+j); sheet.addCell(label); } } workbook.write() workbook.close() } static def readExcel() {&hellip; <a href=\"https:\/\/codethataint.com\/blog\/groovy-writing-and-reading-from-excel\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[222],"tags":[],"class_list":["post-2057","post","type-post","status-publish","format-standard","hentry","category-groovy"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/2057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=2057"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/2057\/revisions"}],"predecessor-version":[{"id":2058,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/2057\/revisions\/2058"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=2057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=2057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=2057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}