473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

about asp.net excel and clipboard

hi:

purpose: clone the firest sheet in Excel.xls into excel2.xls

here is my code
it well done in winform£º
-------------------------------
string SubFile=@"D:\Excel2.xls";
string MainFile=@"D:\Excel.xls";
Excel.Application ExcelMainFileApp,ExcelSubFileApp;
Excel._Workbook ExcelMainFileWorkbook,ExcelSubFileWorkbook;
Excel._Worksheet ExcelMainFileWorksheet,ExcelSubFileWorksheet;
try
{
ExcelMainFileApp = new Excel.Application();

//open source
ExcelMainFileWorkbook=ExcelMainFileApp.Workbooks.O pen(MainFile,Type.Missing,
Type.Missing,Type.Missing,Type.Missing,Type.Missin g,Type.Missing,Type.Missin
g,Type.Missing,Type.Missing,Type.Missing,Type.Miss ing,Type.Missing,Type.Miss
ing,Type.Missing);
ExcelMainFileWorksheet=(Excel._Worksheet)ExcelMain FileWorkbook.ActiveSheet;
string name=ExcelMainFileWorksheet.Name;
ExcelMainFileWorksheet.Cells.Copy(Type.Missing);

ExcelSubFileApp = new Excel.Application();
//destination
ExcelSubFileWorkbook=ExcelSubFileApp.Workbooks.Ope n(SubFile,Type.Missing,Typ
e.Missing,Type.Missing,Type.Missing,Type.Missing,T ype.Missing,Type.Missing,T
ype.Missing,Type.Missing,Type.Missing,Type.Missing ,Type.Missing,Type.Missing
,Type.Missing);
ExcelSubFileWorksheet=(Excel._Worksheet)ExcelSubFi leWorkbook.Sheets.Add(Exce
lSubFileWorkbook.Sheets[ExcelSubFileWorkbook.Sheets.Count],Type.Missing,Type
..Missing,Type.Missing);
ExcelSubFileWorksheet.Paste(Type.Missing,Type.Miss ing);//failed in webform
,when in winform it's ok
foreach (Excel.Workbook book in ExcelSubFileApp.Workbooks)
{
book.Save();
}
ExcelMainFileApp.Workbooks.Close();
ExcelSubFileApp.Workbooks.Close();
ExcelMainFileApp.Quit();
ExcelSubFileApp.Quit();
}
catch( Exception theException )
{
}
finally
{

}
-------------------------------
but when in webform ,it's failed in "
ExcelSubFileWorksheet.Paste(Type.Missing,Type.Miss ing); "

i have configed the DCOM right about excel .
(run dcomcnfg.exe and config Microsoft Excel Application.)
but it's still fail :( (without config it failed in "ExcelMainFileApp =
new Excel.Application();")

anybody knows why?
Nov 17 '05 #1
1 3372
for staters you didn't say what was wrong. secondly, you don't need to
multi-post - this problem has nothing to do with dotnet.framework for
example. there is also a worksheet copy function that you can use to copy
but it uses the system clipboard and you need appropriate permissions

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
--------------------------------------------------
"ʹÃûÑï" <to*************@hotmail.com> wrote in message
news:OO*************@TK2MSFTNGP12.phx.gbl...
hi:

purpose: clone the firest sheet in Excel.xls into excel2.xls

here is my code
it well done in winform£º
-------------------------------
string SubFile=@"D:\Excel2.xls";
string MainFile=@"D:\Excel.xls";
Excel.Application ExcelMainFileApp,ExcelSubFileApp;
Excel._Workbook ExcelMainFileWorkbook,ExcelSubFileWorkbook;
Excel._Worksheet ExcelMainFileWorksheet,ExcelSubFileWorksheet;
try
{
ExcelMainFileApp = new Excel.Application();

//open source
ExcelMainFileWorkbook=ExcelMainFileApp.Workbooks.O pen(MainFile,Type.Missing,
Type.Missing,Type.Missing,Type.Missing,Type.Missin g,Type.Missing,Type.Missin
g,Type.Missing,Type.Missing,Type.Missing,Type.Miss ing,Type.Missing,Type.Miss
ing,Type.Missing);
ExcelMainFileWorksheet=(Excel._Worksheet)ExcelMain FileWorkbook.ActiveSheet;
string name=ExcelMainFileWorksheet.Name;
ExcelMainFileWorksheet.Cells.Copy(Type.Missing);

ExcelSubFileApp = new Excel.Application();
//destination
ExcelSubFileWorkbook=ExcelSubFileApp.Workbooks.Ope n(SubFile,Type.Missing,Typ
e.Missing,Type.Missing,Type.Missing,Type.Missing,T ype.Missing,Type.Missing,T
ype.Missing,Type.Missing,Type.Missing,Type.Missing ,Type.Missing,Type.Missing
,Type.Missing);
ExcelSubFileWorksheet=(Excel._Worksheet)ExcelSubFi leWorkbook.Sheets.Add(Exce
lSubFileWorkbook.Sheets[ExcelSubFileWorkbook.Sheets.Count],Type.Missing,Type
.Missing,Type.Missing);
ExcelSubFileWorksheet.Paste(Type.Missing,Type.Miss ing);//failed in webform
,when in winform it's ok
foreach (Excel.Workbook book in ExcelSubFileApp.Workbooks)
{
book.Save();
}
ExcelMainFileApp.Workbooks.Close();
ExcelSubFileApp.Workbooks.Close();
ExcelMainFileApp.Quit();
ExcelSubFileApp.Quit();
}
catch( Exception theException )
{
}
finally
{

}
-------------------------------
but when in webform ,it's failed in "
ExcelSubFileWorksheet.Paste(Type.Missing,Type.Miss ing); "

i have configed the DCOM right about excel .
(run dcomcnfg.exe and config Microsoft Excel Application.)
but it's still fail :( (without config it failed in "ExcelMainFileApp
=
new Excel.Application();")

anybody knows why?

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stan | last post by:
In the old days of VB6, an Excel chart image could be pasted into a picture box with Clipboard using the following commands. xlApp.ActiveChart.ChartArea.Copy Picture1.Picture =...
0
by: TC | last post by:
Hello, Here is what I'm trying to do: -- Make sure both MS Excel and MS Word are running -- Create an Excel chart -- Save the Excel file -- Copy the Excel chart onto the clipboard using Ctrl...
5
by: TC | last post by:
Hello, Here is what I'm trying to do: -- Make sure both MS Excel and MS Word are running -- Create an Excel chart -- Save the Excel file -- Copy the Excel chart onto the clipboard using Ctrl...
3
by: Otie | last post by:
I am trying to copy the cell contents in an MSFLXGRD control (using VB5) into Excel, retaining the foreground colors of the text and numbers. I have tried using the Clipboard.SetText...
1
by: barma16 | last post by:
I've hit a bit of a brick wall here, and could use some advice. I have an Access application whose output is a four-tab Excel spreadsheet where three of the four tabs are the result of database...
3
by: info | last post by:
After using clipboard functions in Excel controlled from Access VBA, Excel doesn't quit when I use the following ExcelApp.Quit Set ExcelApp = Nothing If I don't use the clipboard functions in...
2
by: ʹÃûÑï | last post by:
hi: purpose: clone the firest sheet in Excel.xls into excel2.xls here is my code it well done in winform£º ------------------------------- string SubFile=@"D:\Excel2.xls"; string...
3
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel...
0
by: Pieter | last post by:
Hi, Is there an 'exact' way to get data in a VB.NET 2005 application that was put on the clipboard in Excel? For instance: When I have an Excel-sheet with 4 values (2 columns, 2 rows) A1...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.