<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Burak BÖLEK - Blog &#187; import</title>
	<atom:link href="http://www.burakbolek.com/blog/tag/import/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.burakbolek.com/blog</link>
	<description>Burak BÖLEK</description>
	<lastBuildDate>Fri, 03 Sep 2010 06:50:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Import AlnDomain from Excel Sheet</title>
		<link>http://www.burakbolek.com/blog/2009/03/import-alndomain-from-excel-sheet/</link>
		<comments>http://www.burakbolek.com/blog/2009/03/import-alndomain-from-excel-sheet/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 20:04:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Maximo Backend Development]]></category>
		<category><![CDATA[Maximo Tips]]></category>
		<category><![CDATA[excel import]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Maximo Connections]]></category>

		<guid isPermaLink="false">http://www.burakbolek.com/blog/?p=33</guid>
		<description><![CDATA[Hello; Now I will explain a bit about importing from excel sheet. Here I will use Jexcel Api to read excel files. This script was written for Maximo 6.2.1, and I will use Jexcel Api 2.6.9 which can be downloaded from here. Here is the code: /* * addAlnDomain.java * * Created on September 2, [...]]]></description>
			<content:encoded><![CDATA[<p>Hello;</p>
<p>Now I will explain a bit about importing from excel sheet. Here I will use Jexcel Api to read excel files. This script was written for Maximo 6.2.1, and I will use Jexcel Api 2.6.9 which can be downloaded from <a href="http://sourceforge.net/project/showfiles.php?group_id=79926&amp;package_id=81471&amp;release_id=642912">here</a>.<br />
Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * addAlnDomain.java
 *
 * Created on September 2, 2008, 4:00 PM
 */</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.PrintStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">jxl.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">psdi.app.system.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">psdi.mbo.MboRemote</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">psdi.util.MXSession</span><span style="color: #339933;">;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author  bbolek
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> addAlnDomain <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/** Creates a new instance of addAlnDomain*/</span>
    <span style="color: #000000; font-weight: bold;">public</span> addAlnDomain<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> add<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> filename<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            MXSession s<span style="color: #339933;">;</span>
            s <span style="color: #339933;">=</span> MXSession.<span style="color: #006633;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            s.<span style="color: #006633;">setHost</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost:9898/MXServer&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Server Name</span>
            s.<span style="color: #006633;">setUserName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wilson&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            s.<span style="color: #006633;">setPassword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wilson&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            s.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            Workbook workbook <span style="color: #339933;">=</span> Workbook.<span style="color: #006633;">getWorkbook</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>filename <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.xls&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Sheet sheet <span style="color: #339933;">=</span> workbook.<span style="color: #006633;">getSheet</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> description, value<span style="color: #339933;">;</span>
                MaxDomainSetRemote maxdomain<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>MaxDomainSetRemote<span style="color: #009900;">&#41;</span> s.<span style="color: #006633;">getMboSet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MAXDOMAIN&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                maxdomain.<span style="color: #006633;">setWhere</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DOMAINID='DOMAINNAME'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                maxdomain.<span style="color: #006633;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                MboRemote maxDomain<span style="color: #339933;">=</span>maxdomain.<span style="color: #006633;">getMbo</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>sheet.<span style="color: #006633;">getCell</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, k<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                value <span style="color: #339933;">=</span> sheet.<span style="color: #006633;">getCell</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, k<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                description <span style="color: #339933;">=</span> sheet.<span style="color: #006633;">getCell</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, k<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;VALUE :&quot;</span><span style="color: #339933;">+</span>value<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; DESCRIPTION: &quot;</span><span style="color: #339933;">+</span>description <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                ALNValueSetRemote alnSet <span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>ALNValueSetRemote<span style="color: #009900;">&#41;</span> maxDomain.<span style="color: #006633;">getMboSet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ALNDOMAINVALUE&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                ALNValueRemote aln <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                aln <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ALNValueRemote<span style="color: #009900;">&#41;</span> alnSet.<span style="color: #006633;">addAtEnd</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                aln.<span style="color: #006633;">setValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;VALUE&quot;</span>, value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                aln.<span style="color: #006633;">setValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DESCRIPTION&quot;</span>, description<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        alnSet.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                k<span style="color: #339933;">++;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> E<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            E.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @param args the command line arguments
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// TODO code application logic here</span>
        addAlnDomain new_AlnDomain <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> addAlnDomain<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        new_AlnDomain.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Example&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In here; between line 28-32 server settings are set. Then on line 34 excel workbook is opened.<br />
On line 35 first sheet is selected. On line 39 the domain with name &#8220;DOMAINNAME&#8221; is selected.<br />
Line 42 shows that the loop will continue if there is a value on the first column of excel.<br />
Line 43 and 44 reads the excel and sets the variables. And on line 48 we create a new ALNDomain mbo. And on 49 we added it to the AlnDomainSet.<br />
Then we bind the variables and save the MboSet&#8230;<br />
On line 62 we set the excel filename&#8230;Here it is <a href="wp-content/uploads/2009/03/example.xls">Example.xls</a></p>
<p>All Mbo&#8217;s can be read from excel and imported to Maximo in this way. It is quite easy and customizable&#8230;For example you can set some rules to import in java like<br />
-import data that starts with 1,<br />
-import data which is like &#8216;%10%&#8217;<br />
-etc&#8230;</p>
<p>Have a good day&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.burakbolek.com/blog/2009/03/import-alndomain-from-excel-sheet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
