|
You've got a full working Excel sample in this directory : <vc7dir>\FrameworkSDK\Samples\Technologies\Interop\Applications\Office\Excel
Behind the wheels, you have to import the Excel typelibrary, which is either ...\Microsoft Office\Office\excel9.olb or ...\Microsoft Office\Office10\excel.exe
depending on the Excel version.
Then you can use the Excel object model as follows :
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Excel;
class AutoExcel {
public static int Main() {
Console.WriteLine ("Creating new Excel.Application");
Application app = new Application();
if (app == null) {
Console.WriteLine("ERROR: EXCEL couldn't be started!");
return 0;
}
Console.WriteLine ("Making application visible");
app.Visible = true;
Console.WriteLine ("Getting the workbooks collection");
Workbooks workbooks = app.Workbooks;
Console.WriteLine ("Adding a new workbook");
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
...
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site. Support for development will ship at the same time as the Windows XP Service Pack 1 (SP1) release.
|
|
|
|
|
Hi
I want to open a tab delimited file in Excel programatically, basically similating me double clicking it. Does anyone have a snippet on how to do this?
Thanx
|
|
|
|
|
System.Diagnostics.Process.Start("filename.xls");
This of course assumes Excel is installed.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
Hi
Thanx, I guess I can do it that way if the file extension (*.tab) association has been made. Unfortunately, I cant assume that.
I was thinking of going thru COM but I'm not sure really. Maybe I must just read a a bit more.
|
|
|
|
|
Oh, huh.
The way I got around this in my program (.xctd -> .xml) was creatign a temporary .xml file and launching that with Process.Start . Dunno how that'd work for you, though.
If you're interested, here's my code for this, inside of the form or wherever:
private ArrayList tempFiles;
private string GetTempFilename(string extension)
{
string tempFilename = Path.GetTempFileName();
File.Move(tempFilename, tempFilename += ("." + extension));
this.tempFiles.Add(tempFilename);
return tempFilename;
}
private void MainForm_Closed(object sender, EventArgs e)
{
foreach(string tempFile in this.tempFiles)
{
File.Delete(tempFile);
}
}
It's not perfect, because the filename is temporary and therefore probably only suitable for restricted purposes.
Otherwise, if you know of any way to ensure that the temp files get cleaned up, I'd appreciate it. Right now, if the user doesn't close IE for my .xml files, they can't be deleted because they're in use.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
|
thz Stephane,
I looked at your other post b4 I even saw this one
StephaneRodriguez wrote:
You've got an Open command in the workbooks object.
Exactly what I was looking for , and stupidly overlooked
|
|
|
|
|
I want to write a windows control.How can I add a custom event handler to it?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
its very simple, first of all, you need to define a Delegate for the event, unless you want to use the EventArgs one. the code sample below shows it all.
public delegate void MyEvent(int SomeEventArgs);
public event MyEvent SomeEvent;
if (SomeEvent != null)
SomeEvent(m_theEventArgs);
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
hmmm,thanks.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
|
http://codeproject.com/dotnet/ntsecuritynet.asp[^]
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
|
Did you use that library or you mean you have error in your code?I didn't have any problem with that library.What is your error?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I have database access for a web service and I want to store config options like multiple database connection strings that an administrator can configure.
How do I do that?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Put a web.config file in the same directory as the web service and put a section in it that looks similar to this:
[Edit: Forgot the configuration tags ]
<configuration>
<appSettings>
<add key="settinga" value="valuea">
</appSettings>
</configuration> Then when you want to retrieve a value use the AppSettings property of the System.Configuration.ConfigurationSettings class just as you would a WinForms application.
for example:
string valuea = System.Configuration.ConfigurationSettings.AppSettings["settinga"];
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thank you.
I am very new to using .NET and C#. When I made the app, I thought I would find this out later and hardcoded the values and then ran out of time.
It is a great relief that fellow guys at CodeProject always has the answers.
modified 29-Aug-18 21:01pm.
|
|
|
|
|
i cannot find how to rename a file in c# can anyone help me out i would be glad for any urgent reply...
|
|
|
|
|
System.IO.File.Move("C:\\this.txt", "C:\\that.txt");
That will rename the file from this.txt to that.txt
David Stone
But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*.
Shog9
|
|
|
|
|
Hi,
I'm trying to create add-in to Visual Studio.Net,
I know how to create Command with a custom icon but I don't know how to set for example green color in this bitmap as transparent
So on my toolbar is very ugly green button
please help me !
Thank you.
|
|
|
|
|
|
Uh I don't know becouse I have this:
<br />
CommandBarButton btn;<br />
Command cmd;<br />
<br />
cmd=applicationObject.Commands.AddNamedCommand<br />
(addInInstance, "MyCmd","Text","Tooltip",<br />
false,1,
ref contextGUIDS,<br />
(int)vsCommandStatus.vsCommandStatusSupported+<br />
(int)vsCommandStatus.vsCommandStatusEnabled);<br />
<br />
btn=MyCmd.AddControl(cmdBar,1) as CommandBarButton;<br />
<br />
I think that I mustn't change picture to be transparent after I create this command.
Maybe I can use btn.Picture and btn.Mask but I don't know how to work with IPictureDisp in C#
|
|
|
|
|
|
According to this article, you need to use a green with an RGB value of (0, 254, 0) the green you are using is probably (0, 255, 0).
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Oh yes!
With RGB(0,254,0) is it better.
Thank you!
|
|
|
|