Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Trying to get multiple time inputs from HTA and add it and generate a formatted .xls file ?

$
0
0

Hi,

I am trying to create an excel sheet by getting the inputs through the help of HTA.

The problem is I am not able to iterate through rows and get the inputs again and again from the user to build on the as much data as anyone wants to feed in the excel.

Below is the script which handles just one time input to one row under the hardcoded headers of the Excel sheet ;

------------------------------------------------------------------------------------------------------------------------------------------------

<html>
<head><title>XLS Data</title>
<HTA:APPLICATION
     APPLICATIONNAME="XLS Data"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>

<script type="text/vbscript">
 
 Sub WriteXL()
 
  Name = document.getElementById("Name").value
  grade=document.getElementById("grade").value
  select case grade
    case "1"
     priority=1
    case "2"
     priority=2
    case "3"
     priority=3
    case "4"
     priority=4
  end select
 
  company = document.getElementById("company").value
  desc = document.getElementById("desc").value
  status = document.getElementById("status").value
 
  Set objExcel = CreateObject("Excel.Application")
  objExcel.Visible = FALSE
  Set objWorkbook = objExcel.Workbooks.Add()
  Set objWorksheet = objWorkbook.Worksheets(1)
  strFileName = "C:\Users\PANSU06\Desktop\ISU.xls"

 
  objWorksheet.Cells(1,1) = "Name"
  objWorksheet.Cells(1,2) = "Company"
  objWorksheet.Cells(1,3) = "Description"
  objWorksheet.Cells(1,4) = "Status"
  objWorksheet.Cells(1,5) = "Grade"
 
  intRow=2
  objExcel.Cells(intRow, 1).Value = Name
  objExcel.Cells(intRow, 2).Value = company
  objExcel.Cells(intRow, 3).Value = desc
  objExcel.Cells(intRow, 4).Value = status
  objExcel.Cells(intRow, 5).Value = grade

  'format 1st Row / Headers
  '-----------------
  x = 1
  Do Until objExcel.Cells(1,x).Value = ""
  objExcel.Cells(1,x).Font.Name = "Copperplate Gothic Bold"
  objExcel.Cells(1,x).Font.Size = 17
  objExcel.Cells(1,x).Interior.ColorIndex = 17
  x = x+1
  Loop
 
  'format whole data sheet except 1st Row
  '-------------------------------
  x = 1
  y = 1
  Do Until objExcel.Cells(x,y).Value = ""
  x = x+1
  Do Until objExcel.Cells(x,y).Value = ""
  objExcel.Cells(x,y).Font.Name = "Cambria"
  objExcel.Cells(x,y).Font.Size = 11
  objExcel.Cells(x,y).Interior.ColorIndex = 19
  y = y+1
  Loop
  Loop
 
  objExcel.Cells.EntireColumn.AutoFit
  objWorkbook.SaveAs(strFileName)
  objExcel.Quit
 
 End Sub
 
</script>

<body>
<form>

 <p>Name: <input type="text" id="Name" max="20" /></p>
 <p>Grade: <select id="grade">
                <option value="4">4</option>
                <option value="3">3</option>
                <option value="2">2</option>
                <option value="1">1</option>
             </select>
  </p>
 <p>Company: <input type="text" id="company" max="50" /></p>
 <p>Description: <BR><TEXTAREA NAME="desc" ROWS=5 COLS=80>Employee Description</TEXTAREA></p>
 <p>Status: <BR><TEXTAREA NAME="status" ROWS=5 COLS=80>Employee status</TEXTAREA></p>
 <p><button onclick="WriteXL">Create XL</button></p>

</form>
</body>
</html>

----------------------------------------------------------------------------------------------------------------------

Please help me if I can get multiple dynamic inputs from the user and fill in the rows iterating one by one. So that users can be able to enter multiple Names, company,description etc..

Hope I explained well what i want to achieve.

Thanks!




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>