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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
sathish kumarPosted Jun 5, 2012, 4:17 AM
Ya i have executed that query after checking all my if conditions....
brunda kPosted Jun 5, 2012, 3:39 AM
In the Code provided, where is the last line "query" been executed?
sathish kumarPosted Jun 5, 2012, 2:59 AM
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 kPosted Jun 5, 2012, 2:52 AM
Kunal VaishyaPosted Jun 5, 2012, 2:43 AM
http://www.c-sharpcorner.com/Blogs/8808/how-to-open-excel-file-in-datagridview.aspx