- Home /
How can I get data from an outside database (specifically excel).
I want to have a bunch of parts whose position updates according to an excel table. The user can press an update button and the positions, sizes, etc will be read from the latest values in the table.
Not to split hairs but Excel is a data source, not a database.
Answer by Herman-Tulleken · Aug 20, 2010 at 02:35 PM
One way to do it is to save the file in the text XML format. From this it should be easy to read in your data using a standard XML parser (such as the one that comes with C#).
Answer by tingham · Nov 05, 2010 at 07:15 PM
public List<string[]> parseCSV(string path) { List<string[]> parsedData = new List<string[]>();
try { using (StreamReader readFile = new StreamReader(path)) { string line; string[] row;
while ((line = readFile.ReadLine()) != null)
{
// Handle quoted values or comma-only.
string splitVar = ( line.indexOf("\",\") > -1 ) ? "\",\"" : "," );
row = line.Split(splitVar);
parsedData.Add(row);
}
}
} catch (Exception e) { MessageBox.Show(e.Message); }
return parsedData; }
Your answer
Follow this Question
Related Questions
Reading an excel file using ExcelReaderFacotry 1 Answer
Create Unity App that read c# files ? 0 Answers
Read XLS file with UTF-8 character; 1 Answer
Keeping object data in an excel sheet? 2 Answers
Unity Sqlite for Android 8.0 0 Answers