8/17/2025 3:27:36 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
Display Excel into Datagrid.
Posted: 04 Jan 09 1:13 AM
|
Hi... all.........
I am trying to read data from excel file and display it into the datagrid without existance of any table in the Database...!
I am able to dispaly colums in the grid by following code...
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open ("D:\Licence1.xls")
intRow = 1 intCol = 1
Do Until objExcel.Cells(1,intCol).Value = "" intCol = intCol + 1 Loop
Do Until objExcel.Cells(intRow,1).Value = "" intRow = intRow + 1 Loop
for i=1 to intCol-1 Set col = Datagrid1.Columns.Add(0)
col.FieldName = objExcel.Cells(1,i).Value 'DNL col.Caption = objExcel.Cells(1,i).Value col.Width = 100 col.ReadOnly = True col.DisableEditor = True
next ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Datagrid1.Columns.Add(0) ---- this property is present for column but not add row.
I have tried following code to add row....!!
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Set objTravelRS = DataGrid1.Recordset objTravelRS.AddNew ---------------- > (error : "Object Required-objTravelRS") objTravelRS.Fields("Column1").Value = "TestValue" DataGrid1.Recordset = objTravelRS
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Is there any other way I can do it...??
--------- Regards Gaurang.
|
|
|
|
Re: Display Excel into Datagrid.
Posted: 04 Jan 09 9:46 AM
|
Yuk, what an unpleasant requirement.
You are trying to walk before you can run. First objective is to get your Excel data into a recordset - I suggest you focus on that bit initially and stop worrying about datagrids until afterwards. If you search the Internet, you will find examples of how to do this. If your spreadsheet is large, this may not be very fast. If you could read instead from a CSV file, it would be quite a bit simpler.
Then build your datagrid columns dynamically using the same fieldnames and datatypes as you have in your Excel spreadsheet.
Then SET the recordset of the dg to be the same as the recordset you have just read.
Then dg.Refresh.
Not tried it, but that is the direction I would head in.
Phil
-- Morning-After Edit-- eek: "Walk before you can run" !!! In future, maybe I should not type posts when I am tired. |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|