15,886,091 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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;
}
}
}
}