Free Support Forum - aspose.com

How do I access a datatable in Aspose.com using SQL command?

Hello,<br><br>  I am reading from the CSV file using Aspose.Cells below is the code I have used to open the CSV file:<br><br>Imports Aspose.Cells<br>...<br>...<br> Private _WorkBook As Workbook = New Workbook<br>...<br>_WorkBook.Open(txtFileName.Text, FileFormatType.CSV)<br><br>Then I imported all the cell from the CSV file into the DataTable as follows:<br><br>_WorkBook.Worksheets(0).Cells.ImportDataTable(_DataTable, False, 0, 0)<br><br>My question is, how do I access these information now using SQL statement? Say for example, I want to do the following SQL statement:<br><br>strSQL = "SELECT * FROM (worksheet name) [Customer] Where Item#=1" and it looks in the datatable for that record and spit out the data. Can anyone help me in this regard? <br><b><br>Remember: I got this information from an excel file with extension CSV and imported it using ImportDataTable into the datatable and I want to extract the information now from the datatable. Can anyone help me please?</b><br>

Hi

Your request is related to another component (Aspose.Cells). That's why I have moved it to the corresponding forum. Their technical support will respond to you soon.

Best regards.

Is it possible you can send me the link where you moved? I really need someone help me in this regard? Thanks in advance.

Hi,

Thanks for considering Aspose.

Well, Aspose.Cells does not support to directly retrieve data using an SQL Query that points to Worksheet (i.e. "SELECT * FROM (worksheet name)...."). I think you may try to write your own code to convert your queries and search directly into your datatable. For example, you may create a dataview object on your base datatable and filter the records for your need and later use Cells.ImportDataView() method to insert those records (stored in dataview object) to worksheet cells.

E.g.,

DataView dv = new DataView (ds.Tables ["Customer"]);

dv.RowFilter = "itemno = 1";

Thank you.