Click here to Skip to main content
12,406,795 members (60,415 online)

Comments by Mark Miller (Top 3 by date)

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;

}
}
}
}

Advertise | Privacy | Mobile
Web02 | 2.8.160730.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid