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
Gomathi Palaniswamy
NA
3.5k
2.2m
Error in copy-paste excel using C#
Dec 13 2011 6:22 AM
The below written for copy and paste excel using c#.here i am facing some error..pls give your idea to solve my error..
Microsoft.Office.Interop.Excel.Application eAPP;
Microsoft.Office.Interop.Excel.Workbook eBOOK;
Microsoft.Office.Interop.Excel.Worksheet eSHEET;
string[] files = System.IO.Directory.GetFiles(@"D:\temp\sankalp_rep");
string filename;
foreach (string flename in files)
{
eAPP = new Microsoft.Office.Interop.Excel.Application();
eBOOK = eAPP.Workbooks.Open(flename, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, false, false);
eBOOK = eAPP.ActiveWorkbook;
eSHEET = (Microsoft.Office.Interop.Excel.Worksheet)eBOOK.ActiveSheet;
eSHEET.Cells.Copy("A2");
if (eAPP.Workbooks.Count <= 1)
{
eAPP = new Microsoft.Office.Interop.Excel.Application();
}
eAPP.Workbooks.Open(@"D:\my.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, false, false);
eBOOK = eAPP.ActiveWorkbook;
eSHEET = (Microsoft.Office.Interop.Excel.Worksheet)eBOOK.ActiveSheet;
eAPP.DisplayAlerts = false;
eSHEET.Paste("A2", "v500");
eSHEET.Cells.Rows.AutoFit();
eAPP.ActiveWindow.Zoom = 60;
eAPP.ActiveWorkbook.Save();
// eAPP.ActiveWorkbook.Close();
eAPP.Quit();
releaseObject(eAPP);
releaseObject(eBOOK);
releaseObject(eSHEET);
}
foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcessesByName("EXCEL"))
{
proc.Kill();
}
Reply
Answers (
3
)
How to sort a DataGrid based on field
Why only the first parameter in the definition of VB.NET Generics uses the 'Of' keyword ?