{"id":132,"date":"2009-04-16T16:36:19","date_gmt":"2009-04-16T21:36:19","guid":{"rendered":"http:\/\/www.1oc.com\/blog\/?p=132"},"modified":"2011-07-14T22:10:39","modified_gmt":"2011-07-15T02:10:39","slug":"read-and-generate-excel-and-word-files","status":"publish","type":"post","link":"http:\/\/blog.1oc.com\/?p=132","title":{"rendered":"Read and Generate Excel and Word files"},"content":{"rendered":"<p>Now you can generate Excel and Word File with NO extra charge, using\u00a0Jakarta POI<\/p>\n<p>Requirements:<\/p>\n<ul>\n<li>.NET Framework 2.0<\/li>\n<li>\u00a0JSharp framework 2.0<\/li>\n<li>Configure your <em><strong>model<\/strong><\/em> to compile and execute with Framework 2.0<\/li>\n<li>DLL from Jakarta poi<\/li>\n<\/ul>\n<p>Install JSharp (<a href=\"http:\/\/blog.1oc.com\/?attachment_id=136\" rel=\"attachment wp-att-136\">vjredist<\/a>)<\/p>\n<p>Install the DLL from Jakarta in your model (<a href=\"http:\/\/blog.1oc.com\/?attachment_id=135\" rel=\"attachment wp-att-135\">jakartapoi-winfx-dll-251-3<\/a>), if you are compiling for WEB, put them on &#8220;DATAxxx\/web\/bin\/&#8221;<\/p>\n<p>Now you are ready to Read or Create Excel or Word files, here an example:<\/p>\n<p>&nbsp;<\/p>\n<p><em>&amp;excel is ExcelDocument Type<\/em><\/p>\n<p><em>Place the &#8220;UseAutomation&#8221; = 0 before the\u00a0&#8220;Open&#8221; command line.<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"Code\"><strong><em>Event \"Excel\" <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0&amp;excel.UseAutomation\u00a0=\u00a00 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0&amp;excel.Open(&amp;File)\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0If\u00a0&amp;excel.ErrCode\u00a0&lt;&gt;\u00a00 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0msg(&amp;excel.ErrDescription) <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0else <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Clear()\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(1,1).Text\u00a0=\u00a0'Customers\u00a0list'\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(1,1).Bold\u00a0=\u00a01 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(1,1).Color\u00a0=\u00a054 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(1,1).Size\u00a0=\u00a010 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(3,1).Text\u00a0=\u00a0'Customer\u00a0Id' <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(3,1).Italic\u00a0=\u00a01 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(3,1).Bold\u00a0=\u00a01 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;row\u00a0=\u00a04 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;col\u00a0=\u00a01 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0For\u00a0each\u00a0line\u00a0in\u00a0Grid <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(&amp;row,&amp;col).Number\u00a0=\u00a0CustomerId <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Cells(&amp;row,&amp;col).Color\u00a0=\u00a03 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;row\u00a0 =\u00a01\u00a0\u00a0\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0endfor\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;excel.Save()\u00a0 <\/em><\/strong><\/span><strong><em> <\/em><\/strong><span style=\"font-family: courier;\"><strong><em>\u00a0\u00a0\u00a0endif EndEvent <\/em><\/strong><\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Now you can generate Excel and Word File with NO extra charge, using\u00a0Jakarta POI Requirements: .NET Framework 2.0 \u00a0JSharp framework 2.0 Configure your model to compile and execute with Framework 2.0 DLL from Jakarta poi Install JSharp (vjredist) Install the &hellip; <a href=\"http:\/\/blog.1oc.com\/?p=132\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-genexus"],"_links":{"self":[{"href":"http:\/\/blog.1oc.com\/index.php?rest_route=\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.1oc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.1oc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.1oc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.1oc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=132"}],"version-history":[{"count":2,"href":"http:\/\/blog.1oc.com\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":396,"href":"http:\/\/blog.1oc.com\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions\/396"}],"wp:attachment":[{"href":"http:\/\/blog.1oc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.1oc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.1oc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}