arunbh
asked on
how refresh excel sheet without open the file.
how i can refresh excel sheet without opening the file by using the asp.net c# code..
this is my code but their have problume .
///======================= ========== ========== ==
string EFile = "BExcel.xls";
string ESFile = @System.Windows.Forms.Appl ication.St artupPath + "\\ExcelFile\\" + EFile;
EXL = new Excel.Application();
EXL.DisplayFullScreen = false;
try
{
EXL.WindowState = Excel.XlWindowState.xlMaxi mized;
}
catch
{
MessageBox.Show("Please resize your Excel window size");
}
System.Windows.Forms.Appli cation.DoE vents();
//Workbook book =EXL.Workbooks.Add(ESFile) ;
Workbook book = EXL.Workbooks.Add(ESFile);
System.Windows.Forms.Appli cation.DoE vents();
book.RefreshAll();
System.Windows.Forms.Appli cation.DoE vents();
System.Windows.Forms.Appli cation.DoE vents();
Worksheet sheet = (Worksheet)book.ActiveShee t;
System.Windows.Forms.Appli cation.DoE vents();
System.Windows.Forms.Appli cation.DoE vents();
//======================== ========== ========== =
this is my code but their have problume .
///=======================
string EFile = "BExcel.xls";
string ESFile = @System.Windows.Forms.Appl
EXL = new Excel.Application();
EXL.DisplayFullScreen = false;
try
{
EXL.WindowState = Excel.XlWindowState.xlMaxi
}
catch
{
MessageBox.Show("Please resize your Excel window size");
}
System.Windows.Forms.Appli
//Workbook book =EXL.Workbooks.Add(ESFile)
Workbook book = EXL.Workbooks.Add(ESFile);
System.Windows.Forms.Appli
book.RefreshAll();
System.Windows.Forms.Appli
System.Windows.Forms.Appli
Worksheet sheet = (Worksheet)book.ActiveShee
System.Windows.Forms.Appli
System.Windows.Forms.Appli
//========================
ASKER
this code help open an Excel Sheet then system create temp excel sheet in refresh mood but that excel sheet have without (.xls). If i try more time then error produce.
Do you close your excel-application in your code or not ?
ASKER
when more time active an excel sheet then this error produce:---{ Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))}.
task Manager Processes there have more EXCEL.EXE is running.
I use process that help kill the process after some time produce same Error.
I Use BExcel.xls file there have data relation between MS Access table
If I change in database then change the Excel File Data.
task Manager Processes there have more EXCEL.EXE is running.
I use process that help kill the process after some time produce same Error.
I Use BExcel.xls file there have data relation between MS Access table
If I change in database then change the Excel File Data.
Worksheet sheet = (Worksheet)book.ActiveShee t;
System.Windows.Forms.Appli cation.DoE vents();
System.Windows.Forms.Appli cation.DoE vents();
....
at the end of your procedure:
EXL.close
set book = nothing
set sheet = nothing
set EXL = nothing
System.Windows.Forms.Appli
System.Windows.Forms.Appli
....
at the end of your procedure:
EXL.close
set book = nothing
set sheet = nothing
set EXL = nothing
ASKER
Hi
Dhaest :
I am also doing same but thats not sutisfy me
this is my code please give me any code for this solution
this very urgent me please give any solution
private void RFExcel()
{
System.Diagnostics.Process [] ExcelPro = System.Diagnostics.Process .GetProces ses();
foreach (System.Diagnostics.Proces s ProParent in ExcelPro)
{
System.Diagnostics.Process [] ProName = System.Diagnostics.Process .GetProces sesByName( ProParent. ProcessNam e);
foreach (System.Diagnostics.Proces s ProChild in ProName)
{
try
{
DPValue = ProChild.ProcessName.ToStr ing();
if (DPValue.Equals("EXCEL"))
{
ProChild.Kill();
ProChild.Close();
ProChild.Dispose();
}
}
catch (Exception EX)
{
label1.Text = "Error!..." + EX.Message.ToString();
}
}
}
StartExcelRefresh();
}
private void StartExcelRefresh()
{
string EFile = "BExcel.xls";
string ESFile = @System.Windows.Forms.Appl ication.St artupPath + "\\ExcelFile\\" + EFile;
EXL = new Excel.Application();
EXL.DisplayFullScreen = false;
try
{
EXL.WindowState = Excel.XlWindowState.xlMaxi mized;
//EXL.WindowState = Excel.XlWindowState.xlNorm al;
//EXL.Left = 0; EXL.Width = 770;
//EXL.Top = 49.5; EXL.Height = 494;
}
catch
{
MessageBox.Show("Please resize your Excel window size");
}
System.Windows.Forms.Appli cation.DoE vents();
Workbook book = EXL.Workbooks.Add(ESFile);
System.Windows.Forms.Appli cation.DoE vents();
book.RefreshAll();
System.Windows.Forms.Appli cation.DoE vents();
System.Windows.Forms.Appli cation.DoE vents();
Worksheet sheet = (Worksheet)book.ActiveShee t;
System.Windows.Forms.Appli cation.DoE vents();
System.Windows.Forms.Appli cation.DoE vents();
disposeExisObj();
}
private void disposeExisObj()
{
try
{
if (EXL != null)
{
//----------------
EXL.Visible = false;
EXL.DisplayAlerts = false;
EXL.Quit();
EXL = null;
EXL = Close();
GC.Collect();
GC.WaitForPendingFinalizer s();
GC.Collect();
GC.WaitForPendingFinalizer s();
}
}
catch
{
}
}
Dhaest :
I am also doing same but thats not sutisfy me
this is my code please give me any code for this solution
this very urgent me please give any solution
private void RFExcel()
{
System.Diagnostics.Process
foreach (System.Diagnostics.Proces
{
System.Diagnostics.Process
foreach (System.Diagnostics.Proces
{
try
{
DPValue = ProChild.ProcessName.ToStr
if (DPValue.Equals("EXCEL"))
{
ProChild.Kill();
ProChild.Close();
ProChild.Dispose();
}
}
catch (Exception EX)
{
label1.Text = "Error!..." + EX.Message.ToString();
}
}
}
StartExcelRefresh();
}
private void StartExcelRefresh()
{
string EFile = "BExcel.xls";
string ESFile = @System.Windows.Forms.Appl
EXL = new Excel.Application();
EXL.DisplayFullScreen = false;
try
{
EXL.WindowState = Excel.XlWindowState.xlMaxi
//EXL.WindowState = Excel.XlWindowState.xlNorm
//EXL.Left = 0; EXL.Width = 770;
//EXL.Top = 49.5; EXL.Height = 494;
}
catch
{
MessageBox.Show("Please resize your Excel window size");
}
System.Windows.Forms.Appli
Workbook book = EXL.Workbooks.Add(ESFile);
System.Windows.Forms.Appli
book.RefreshAll();
System.Windows.Forms.Appli
System.Windows.Forms.Appli
Worksheet sheet = (Worksheet)book.ActiveShee
System.Windows.Forms.Appli
System.Windows.Forms.Appli
disposeExisObj();
}
private void disposeExisObj()
{
try
{
if (EXL != null)
{
//----------------
EXL.Visible = false;
EXL.DisplayAlerts = false;
EXL.Quit();
EXL = null;
EXL = Close();
GC.Collect();
GC.WaitForPendingFinalizer
GC.Collect();
GC.WaitForPendingFinalizer
}
}
catch
{
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
Dhaest
Thanks more to support me. I will try this code. If any problems then i will contact to you.
Dhaest
Thanks more to support me. I will try this code. If any problems then i will contact to you.
Can you give some feedback if one of the answers was sufficient or do you still have any problems ?
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
EXL = new Excel.Application();
EXL.Visible = false;
EXL.DisplayFullScreen = false;