473,606 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\Ex cel2.xls";
string MainFile=@"D:\E xcel.xls";
Excel.Applicati on ExcelMainFileAp p,ExcelSubFileA pp;
Excel._Workbook ExcelMainFileWo rkbook,ExcelSub FileWorkbook;
Excel._Workshee t ExcelMainFileWo rksheet,ExcelSu bFileWorksheet;
try
{
ExcelMainFileAp p = new Excel.Applicati on();

//open source
ExcelMainFileWo rkbook=ExcelMai nFileApp.Workbo oks.Open(MainFi le,Type.Missing ,
Type.Missing,Ty pe.Missing,Type .Missing,Type.M issing,Type.Mis sing,Type.Missi n
g,Type.Missing, Type.Missing,Ty pe.Missing,Type .Missing,Type.M issing,Type.Mis s
ing,Type.Missin g);
ExcelMainFileWo rksheet=(Excel. _Worksheet)Exce lMainFileWorkbo ok.ActiveSheet;
string name=ExcelMainF ileWorksheet.Na me;
ExcelMainFileWo rksheet.Cells.C opy(Type.Missin g);

ExcelSubFileApp = new Excel.Applicati on();
//destination
ExcelSubFileWor kbook=ExcelSubF ileApp.Workbook s.Open(SubFile, Type.Missing,Ty p
e.Missing,Type. Missing,Type.Mi ssing,Type.Miss ing,Type.Missin g,Type.Missing, T
ype.Missing,Typ e.Missing,Type. Missing,Type.Mi ssing,Type.Miss ing,Type.Missin g
,Type.Missing);
ExcelSubFileWor ksheet=(Excel._ Worksheet)Excel SubFileWorkbook .Sheets.Add(Exc e
lSubFileWorkboo k.Sheets[ExcelSubFileWor kbook.Sheets.Co unt],Type.Missing,T ype
..Missing,Type. Missing);
ExcelSubFileWor ksheet.Paste(Ty pe.Missing,Type .Missing);//failed in webform
,when in winform it's ok
foreach (Excel.Workbook book in ExcelSubFileApp .Workbooks)
{
book.Save();
}
ExcelMainFileAp p.Workbooks.Clo se();
ExcelSubFileApp .Workbooks.Clos e();
ExcelMainFileAp p.Quit();
ExcelSubFileApp .Quit();
}
catch( Exception theException )
{
}
finally
{

}
-------------------------------
but when in webform ,it's failed in "
ExcelSubFileWor ksheet.Paste(Ty pe.Missing,Type .Missing); "

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 "ExcelMainFileA pp =
new Excel.Applicati on();")

anybody knows why?
Nov 17 '05 #1
1 3381
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.framewor k 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******** *****@TK2MSFTNG P12.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:\Ex cel2.xls";
string MainFile=@"D:\E xcel.xls";
Excel.Applicati on ExcelMainFileAp p,ExcelSubFileA pp;
Excel._Workbook ExcelMainFileWo rkbook,ExcelSub FileWorkbook;
Excel._Workshee t ExcelMainFileWo rksheet,ExcelSu bFileWorksheet;
try
{
ExcelMainFileAp p = new Excel.Applicati on();

//open source
ExcelMainFileWo rkbook=ExcelMai nFileApp.Workbo oks.Open(MainFi le,Type.Missing ,
Type.Missing,Ty pe.Missing,Type .Missing,Type.M issing,Type.Mis sing,Type.Missi n
g,Type.Missing, Type.Missing,Ty pe.Missing,Type .Missing,Type.M issing,Type.Mis s
ing,Type.Missin g);
ExcelMainFileWo rksheet=(Excel. _Worksheet)Exce lMainFileWorkbo ok.ActiveSheet;
string name=ExcelMainF ileWorksheet.Na me;
ExcelMainFileWo rksheet.Cells.C opy(Type.Missin g);

ExcelSubFileApp = new Excel.Applicati on();
//destination
ExcelSubFileWor kbook=ExcelSubF ileApp.Workbook s.Open(SubFile, Type.Missing,Ty p
e.Missing,Type. Missing,Type.Mi ssing,Type.Miss ing,Type.Missin g,Type.Missing, T
ype.Missing,Typ e.Missing,Type. Missing,Type.Mi ssing,Type.Miss ing,Type.Missin g
,Type.Missing);
ExcelSubFileWor ksheet=(Excel._ Worksheet)Excel SubFileWorkbook .Sheets.Add(Exc e
lSubFileWorkboo k.Sheets[ExcelSubFileWor kbook.Sheets.Co unt],Type.Missing,T ype
.Missing,Type.M issing);
ExcelSubFileWor ksheet.Paste(Ty pe.Missing,Type .Missing);//failed in webform
,when in winform it's ok
foreach (Excel.Workbook book in ExcelSubFileApp .Workbooks)
{
book.Save();
}
ExcelMainFileAp p.Workbooks.Clo se();
ExcelSubFileApp .Workbooks.Clos e();
ExcelMainFileAp p.Quit();
ExcelSubFileApp .Quit();
}
catch( Exception theException )
{
}
finally
{

}
-------------------------------
but when in webform ,it's failed in "
ExcelSubFileWor ksheet.Paste(Ty pe.Missing,Type .Missing); "

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 "ExcelMainFileA pp
=
new Excel.Applicati on();")

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
3839
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 = Clipboard.GetData() I having problems doing this in VB.net? I tried the code shown below, but it does not work. Its a modified version
0
2115
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 + C -- Go to Word and look under Edit > Paste Special -- Note there is a source reference and an option to paste the chart as a
5
4041
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 + C -- Go to Word and look under Edit > Paste Special -- Note there is a source reference and an option to paste the chart as a
3
10192
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 msflxgrd1.Clip command, but that ignores the colors. I have tried to write rtf-coded text to the clipboard using: Clipboard.SetText rtf_Text, -16639
1
6184
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 queries. A number of fields in the queries are designed to become formulae in Excel after the export has taken place (and they need to be in Excel rather than Access). I need to use the TransferSpreadsheet Method rather than the OutputTo to enable...
3
3433
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 my Access code, Excel is terminated properly. I have seen discussions on this subject by can't find the answer to my
2
1433
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 MainFile=@"D:\Excel.xls"; Excel.Application ExcelMainFileApp,ExcelSubFileApp;
3
9898
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 (SP1) installed. The error is: System.Runtime.InteropServices.COMException(0x800A03EC): Exception from HRESULT: 0x800A03EC. at Microsoft.Office.Interop.Excel._Worksheet.Paste(Object Destination, Object Link) at...
0
1944
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 B1 A2 B2
0
8439
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8094
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8305
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5465
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2448
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1553
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1296
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.