Hi friends,
i want to read .xls, xlsx, file format (using c#.net with sql connection) and have to save that file content into my folder.
Any1 help me please...
Thanks In ADVANCE...........................
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kunal VaishyaRank #990 · 2K reputationPosted Jun 4, 2012, 10:43 PM EDT
http://www.c-sharpcorner.com/Blogs/8808/how-to-open-excel-file-in-datagridview.aspx
brunda kRank #3,804 · 389 reputationPosted Jun 4, 2012, 10:52 PM EDT
sathish kumar115 reputationPosted Jun 4, 2012, 10:59 PM EDT
i have to read file in such a way i have shown below... Below shown is the .docx file read format.. Same way i have to read .xls, .xlsx and pdf file format...after reading the file i have to save that file content in my folder.
if (extn.Equals(".docx"))
{
Microsoft.Office.Interop.Word.ApplicationClass oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object fileName = Server.MapPath("uploads/" + filename);
object readOnly = true;
object isVisible = false;
object missing = System.Reflection.Missing.Value;
//Word.ApplicationClass oWordApp = new Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
//oWordDoc.Activate();
oWordDoc.ActiveWindow.Selection.WholeStory();
oWordDoc.ActiveWindow.Selection.Copy();
string txt = oWordDoc.Content.Text;
query = "INSERT INTO Fileupload([category],[subcategory],[uid],[oid],[up_name],[demo1],[keyword],[fdata],[aflag],sizebyte) VALUES('" + dropcategory.SelectedValue + "','" + DropDownList1.SelectedValue + "','" + Session["user_id"].ToString() + "','" + txtOwnerId.SelectedItem + "','" + fname + "','" + demo1.Text + "','" + key + "','" + txt + "',1,'" + size + "') ";
}
brunda kRank #3,804 · 389 reputationPosted Jun 4, 2012, 11:39 PM EDT
In the Code provided, where is the last line "query" been executed?
sathish kumar115 reputationPosted Jun 5, 2012, 12:17 AM EDT
Ya i have executed that query after checking all my if conditions....