Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2005

Tip: Looking for answers? Try searching our database.

about asp.net excel and clipboard

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ʹÃûÑï - 24 Apr 2005 08:01 GMT
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.Open(MainFile,Type.Missing,
Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missin
g,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Miss
ing,Type.Missing);

ExcelMainFileWorksheet=(Excel._Worksheet)ExcelMainFileWorkbook.ActiveSheet;
   string name=ExcelMainFileWorksheet.Name;
   ExcelMainFileWorksheet.Cells.Copy(Type.Missing);

   ExcelSubFileApp = new Excel.Application();

//destination
ExcelSubFileWorkbook=ExcelSubFileApp.Workbooks.Open(SubFile,Type.Missing,Typ
e.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,T
ype.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing
,Type.Missing);
ExcelSubFileWorksheet=(Excel._Worksheet)ExcelSubFileWorkbook.Sheets.Add(Exce
lSubFileWorkbook.Sheets[ExcelSubFileWorkbook.Sheets.Count],Type.Missing,Type
.Missing,Type.Missing);
ExcelSubFileWorksheet.Paste(Type.Missing,Type.Missing);//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.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  "ExcelMainFileApp =
new Excel.Application();")

anybody knows why?
Alvin Bruney [Microsoft MVP] - 24 Apr 2005 15:12 GMT
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

Signature

Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
--------------------------------------------------

> hi:
>
[quoted text clipped - 61 lines]
>
> anybody knows why?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.