TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
KarDinal Royce
NA
1
890
selcting excel range or cells & export to sql using asp.net
Feb 8 2016 6:39 AM
I want to import data from Excel using range or cell, like data from row '9' to column 'G'...all the data within these rows and columns will be Exported from excel to sql data table, and this i want to achieve through asp.net.
it is like using X axis and Y axis .
i have code to import the whole file
string csvPath = Server.MapPath("~/Files/") + Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(csvPath);
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("KPI", typeof(string)),
new DataColumn("KPIPN", typeof(string)),
new DataColumn("KPIPV", typeof(string))});
string csvData = File.ReadAllText(csvPath);
foreach (string row in csvData.Split('\n'))
{
if (!string.IsNullOrEmpty(row))
{
dt.Rows.Add();
int i = 0;
foreach (string cell in row.Split(','))
{
dt.Rows[dt.Rows.Count - 1][i] = cell;
i++;
}
using (SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(con))
{
sqlbulkcopy.DestinationTableName = "dbo.csv";
sqlbulkcopy.WriteToServer(dt);
con.Close();
}
Reply
Answers (
1
)
Sending textbox data to another page
DaypilotMonth event color change