Forum Discussion
Dear robert,
Using the workspace --> temp var --> <var>
which is a DB table with default value {Worksheet: "Sheet1"; workbook: "CommandDatabase.xls"}
Best regards,
Jewest
OK, so you're using a Project or ProjectSuite variable for your excel data.
What you will probably need to do is replace that with script code. I'm assuming you're doing a read-only view of the data table. So, I would use the DDT.ExcelDriver method call to create an object to retrieve the data from the excel table.
In that method, you reference the name of the Excel file you want to use. Replace that with a variable. So, here's some pseudo-code. Understand this is REALLY pseudo code and does not necessarily match a known syntax or structure, just presented to give the general idea.
var deviceName = CheckDevice() // <- some function or method to determine the device var excelFileName; case deviceName of 'device1' : excelFileName = 'device1.xlsx' 'device2' : excelFileName = 'device2.xlsx' else : excelFileName = 'default.xlsx' var databaseDriver = DDT.ExcelDriver('C:\\DataStore\\' + excelFileName, 'DATA', true)
- jewe6 years agoOccasional Contributor
I understand the idea, the only problem is that this object does not have the same interface as the DB Table.
Is there a property or a casting possible?
I could not find it in the TC documentation.
- tristaanogre6 years agoEsteemed Contributor
No, there is not a casting available. My suggestion is that you move away from using the DBTable variable type and move to the DDT object.
Again, that is depending a bit on what you are doing with the data. The DDT object creates, essentially, a data record set that can be iterated through row by row, usually in a while loop.
If, however, you need something more direct, you can use the Excel.Application object to access the excel workbook. The code is different but, again, you may need to rework how you are consumming the data object.
Basically... there is no way to do what you are wanting to do using the DB Table variable type. So, you need to convert to use a different method of connecting to your Excel database so you can have a more variable way of opening the files.
Related Content
- 3 years agoOfer-Yaniv
Recent Discussions
- 10 hours agojstaehlin
- 2 days agoAivanitskiy