Click here to Skip to main content
15,886,091 members

Comments by Mark Miller (Top 4 by date)

Mark Miller 18-Aug-20 8:16am View    
Got it, thanks, and thanks for the Indexer idea. Works like a charm.
Mark Miller 9-Jul-15 14:41pm View    
Try changing this line:
text = range.Cells[i, j].ToString();
to this:
text = range.Cells[i, j].Value2.ToString();

See also:
http://csharp.net-informations.com/excel/csharp-read-excel.htm
http://www.codeproject.com/Articles/252962/Excel-Automation-With-Clean-Exit-Quit
Mark Miller 2-Jul-15 10:26am View    
Try this:

// Find existing record, load into object
var customObject = dbContext.CustomObjects.Find(Id);

// Set individual properties on the object pulled from the DB
customObject.Property1 = newObject.Property1;
customObject.Property2 = newObject.Property2;
dbContext.Entry(customObject).State = System.Data.EntityState.Modified;
dbContext.SaveChanges();
Mark Miller 2-Jul-15 10:23am View    
Yes, change the foreach as follows:
string text = range.Cells[i, j].ToString();
string[,] list = new string[i, j];

foreach (Excel.Worksheet excelWorksheet1 in excelWorkbook.Sheets)
{
for (int a = 1; a <= i; a++)
{
for (int b = 1; b <= j; b++)
{
text = range.Cells[i, j].ToString();
if (!text.Equals(null))
{
list[a - 1, b - 1] = text;

}
}
}
}