title: Read From Excel and Write That Data into HTA Application
body: <p>Here is the VBscript and HTA code to read the data from Excel and paste that data into editable <code>&lt;div&gt;</code> using HTA application and write updated data from <code>&lt;div&gt;</code> and paste that updated data again in Excel when I click the buttons accordingly.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
  &lt;link href="D:\VBScriptTrainee\bootstrap-3.3.6-dist\css\bootstrap.min.css" rel="stylesheet"&gt;
  &lt;HTA:application
    ICON= "D:\VBScriptTrainee\Ampeross-Qetto-Icon-developer.ico"
    APPLICATIONNAME="myApp"
    BORDER="dialog"
    BORDERSTYLE="complex"
    CAPTION="yes"
    MAXIMIZEBUTTON="yes"
    MINIMIZEBUTTON="yes"
    SHOWINTASKBAR="yes"
    SINGLEINSTANCE="no"
    SYSMENU="yes"
    VERSION="2.0"
    WINDOWSTATE="maximize"
    SCROLLFLAT="yes"
    SYSMENU="no"/&gt;
  &lt;title&gt;Read Excel&lt;/title&gt;
  
  &lt;style type="text/css"&gt;
  body { background-color: #1abc9c; }
  p    { font:bold 18px arial; }
  &lt;/style&gt;
  
  &lt;script language="vbscript"&gt;
  Public mySpan,selectexcel,objExcel,objWorkbook,rowCount,colCount,rowData,textdata,sp,b,word
  
  On Error Resume Next
  
  Sub ReadExcelData()
      Set mySpan = document.getElementById("Span_id_two")
  
      mySpan.InnerText = " " 
  
      selectexcel = InputBox("Enter the location","Location of the excel file(Xls/xlsx)","Enter your path here !")
  
      Set objExcel = CreateObject("Excel.Application")
      Set objWorkbook = objExcel.Workbooks.Open(selectexcel)
      objExcel.Visible = True
  
      rowCount = objExcel.ActiveWorkbook.Sheets(1).UsedRange.Rows.Count
      colCount = objExcel.ActiveWorkbook.Sheets(1).UsedRange.Columns.Count
  
      Dim mySpan
  
      colCount = colCount+1
  
      MsgBox("colCount" &amp; colCount)
  
      For intRow=1 To rowCount Step 1
          rowData = Null
  
          For intCol=1 To colCount Step 1        
              rowData = rowData &amp; "    " &amp; objExcel.Cells(intRow, intCol).Value &amp; "|"
          Next
  
           Set mySpan = document.getElementById("Span_id_two")
           mySpan.InnerHTML =  mySpan.InnerHTML &amp; rowData &amp; "&lt;br&gt;"
      Next
  End Sub
  
  Sub WriteExcelData()
      Set mySpan = document.getelementbyid("Span_id_two")
  
      textdata = mySpan.InnerHTML
  
      ReDim words(-1)
      For Each line In Split(textdata, "|")
         For Each word In Split(line, "&lt;BR&gt;")
             For Each wordTwo In Split(word,vbnewLine)
                 ReDim Preserve words(UBound(words)+1)
                 words(UBound(words)) = wordTwo
             Next
         Next
      Next
  
      k = 0
  
      MsgBox("colCount" &amp; colCount)
  
      For i=1 To rowCount Step 1
         For j=1 To colCount Step 1
            objExcel.Cells(i, j).Value = words(k)
            k = k+1
         Next
      Next
  
      objExcel.Activeworkbook.Save
      objExcel.Quit
  
      Set objExcel = Nothing
  End Sub
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;center&gt;&lt;img src="Excel.png" height=200 width=300/&gt;&lt;/center&gt;
  &lt;center&gt;
  &lt;h1 align="center" style="color:blue"&gt;&lt;img src="icon-developer-icon.png" height=100px width=100px/&gt;Read Excel (Row by Row)&lt;/h1&gt;&lt;br/&gt;
  &lt;button class="btn btn-success" name="Read" value="Click To Read" onclick="ReadExcelData()"&gt;Click To Read&lt;/button&gt;
  &lt;button class="btn btn-danger" name="Write" value="Click To Write" onclick="WriteExcelData()" &gt;Click To Write&lt;/button&gt;
  &lt;/center&gt;
  
  &lt;br&gt;
  &lt;br&gt;
  
  &lt;div&gt;
    &lt;center&gt;
    &lt;table border="2px" color="Red"&gt;
      &lt;th id="thead"&gt;&lt;/th&gt;
      &lt;tr&gt;
        &lt;td&gt;
          &lt;br&gt;
          &lt;div class="jumbotron"&gt;
            &lt;div contenteditable="true" ID="Span_id_two" style="color:blue;" name="text_name"&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;br&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
    &lt;marquee direction="Right" style="color:red;" &gt;****Note : Only Select Excel file****&lt;/marquee&gt;
    &lt;/center&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>In this, I have split the Excel values using <code>|</code> character, but I want to display the cell values in tabular format using borders for each cell value.</p>