|
<code>
ApplicationClass excelApplication;
Workbook excelWorkBook;
Worksheet excelWorkSheet;
excelApplication = new ApplicationClass();
excelWorkBook = excelApplication.Workbooks.Add(Type.Missing);
excelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) excelWorkBook.ActiveSheet;
excelWorkSheet.get_Range(excelWorkSheet.Cells[1,1],excelWorkSheet.Cells[1,2]).Merge(Type.Missing);
excelWorkSheet.Cells[1,1] = "Merged Text";
excelWorkSheet.get_Range("A1","A1").Interior.ColorIndex = 37;
excelWorkSheet.get_Range("A1","A1").Interior.Pattern = XlPattern.xlPatternSolid;
excelWorkSheet.get_Range("A1","A1").Font.Bold = true;
excelWorkBook.SaveAs("C:\\NewExcel_CSharp.xls",Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
excelApplication.Quit();
</code>
and for that you need
Microsoft.Office.Interop.Excel.dll
|
|
|
|
|
hi abhijit,
Thanx for your response.But I am sorry that your code is not resolving my
problem.All i want is to group/ungroup rows(collapse/expand) using c#.
ex: In excel select some rows and go to Data->Group and Outline and select
group.It will collapse rows with mark '+'.This i want through c# code.
|
|
|
|
|
Hello everyone,
I am trying to get the IP Address of the client so the application can hook itself up to it. I am using the following code:
private void MyApplicationForm_Load(object sender, EventArgs e)
{
string strIP = null;
IPHostEntry HosyEntry = Dns.GetHostEntry((Dns.GetHostName()));
if (HosyEntry.AddressList.Length > 0)
{
foreach (IPAddress ip in HosyEntry.AddressList)
{
strIP = ip.ToString();
cmbInterfaces.Items.Add(strIP);
}
}
}
When I run the application on my PC which is connected via a cable to a routher I only get on IP address which is the internal IP address. But when I run the Application on my laptop which is using Wireless Connection to the same routher I get list of few IP addresses. Can someone tell me why this is the case and how can I make sure I only the IP address that my laptop is set to rather than the list of the IP addresses.
Thank you very much and have a great day.
|
|
|
|
|
Hi!
I think you have a basic misconception here:
Any given PC doesn't have "the one IP address", it all depends on the network connections you have.
Worst case: No network at all, so the PC doesn't have an IP address at all.
In all the other cases, each network interface can (and usually will) have a different IP address. Try opening a command shell and executing "ipconfig /all", you'll see the settings and IP addresses for all the network interfaces.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
hi
I don't know how I can give address of specify process
can you help me
regard
|
|
|
|
|
I am creating a simple program that reads and writes files to a database. I have SequetialAccess for reading the data down, it works great, and is very very efficient.
The problem I have is with writing to the database. I can only write the file BLOB in one big, very slow chunk. I want to be able to create a buffer and write in buffered intervals.
Any suggestions.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hi i trying to search for values in .txt file and return the existings lines
But how can i trim down the string[] Chunk to -3 letters??
for example:
.txt file look like this
#
k441122
blabla
blabla
blabla
blabla
if i search for k441 than return the k441122 with all the existings lines?
i have tryade Chunk.Substring(0 , 4)
Any idea??
My code look like this:
private bool ReadChunk(StreamReader sr, out string[] Chunk, string MatchData)
{
Chunk = new string[9];
bool FoundMatch = false;
for (int i = 0; i < 9; i++)
{
try
{
Chunk[i] = sr.ReadLine();
if (i == 1 && Chunk[i] == MatchData)
{
FoundMatch = true;
}
}
catch (Exception ex)
{
FoundMatch = false;
}
}
return FoundMatch;
}
Big Tnx!!
|
|
|
|
|
Use Regex.
if (Regex.IsMatch(szStringToSearch, szPatternToFind, RegexOptions.IgnoreCase))<br />
{<br />
MessageBox.Show("Success");<br />
}
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hey guys,
I need your help with 2 things on a DataGridView in VS2005.
1) I need a cell to have 1 row in it underlined, e.g:
<underlined> hello
world
2) I need to have a border between 2 lines in the DataGridView highlighted (bolded, colored etc)
Thanks!
|
|
|
|
|
I am making a project that is due soon and one of the last things i need to do is set frmSearch as a child of the parent form frmMain.
Here is my problem
I have frmMain, when it opens I click on a button that opens frmEmployeeInfo. This is a child form and works well. On this frmEmployeeInfo there is a button that takes me to the form frmSearch. I am having problems setting frmSearch as a child of frmMain. Is there a way to do this.
I have tried everything. I tried creating a method in frmMain and calling it in frmEmployeeInfo (supposed to open the frmSearch and set it as child), i tired a lot of other stuff, and I am getting down to the wire.
Please help
And I thank you in advance. I will be on line refreshing this page every couple of mins if you need more explination.
Thanks again
Kyle
|
|
|
|
|
Set the Owner or Parent of the new child form to be the owner/parent of the form that is creating it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Im a little confused. What do you mean?
Kyle Maldonado
|
|
|
|
|
Each windows from has a method called Show and ShowDialog. Each of these methods has an overload that accepts an IWin32Window). The MSDN documentation states that the IWin32Window is any "object that implements System.Windows.Forms.IWin32Window and reprepsents a top-level window that will own this form.
If you were to do frmSearch.ShowDialog(someFormName), I think this would accomplish what you are after.
|
|
|
|
|
Apart from the above post, i'm pretty sure setting the forms .Owner and .Parent properties would work.
Also, to get main form from your employee form, use this.Parent . That will give you a reference to frmMain.
frmSearch = new frmSearch();<br />
frmSearch.ShowDialog(this.Parent);
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
Will this let me pass data from frmSearch to frmEmployeeInfo?
I need to pass RecId from frmSearch to frmEmployeeInfo because I need to read a record and populate the listbox in frmEmployeeInfo.
Thanks again, you guys are a life savor.
Kyle
Kyle Maldonado
|
|
|
|
|
you should not interlink two forms to much (of course you could give the constructor of frmSearch a reference to a frmEmployeeInfo-object and use some public function of frmEmployeeInfo to do this - but I would advise against it) - better use something like:
- a event in frmSearch to post the info
- a callback-delegate that is passed to frmSearch (this is more or less the same than using an event - but the event has better VS-integration
- a public function/property on frmSearch to query the data
I would advise:
- if you call the frmSearch as an modal dialog use the public property approach
- if not use the callback-delegate approach
|
|
|
|
|
Hi i have written the code below, its job is to bring up a popup when a button is clicked, however although the popup comes up when information is entered into the popup it brings back an error saying, input string was not in correct format.
Hi that works but it doesnt take across "WorkSchedule_ID" because although the popup loads, when i enter information into it, the result is still "input string was not in a correct format". I tried this but it didnt work, the offending line is "strPrimaryKey =e.Item.DataBind("WorkSchedule_ID").ToString;". WorkSchedule_ID is coming from the database and each recored has its on unique ID, how can i pass it through to the page?
protected void btnModify_Click(Object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Submit")
{
string strPrimaryKey = (string)e.CommandArgument;
strPrimaryKey =e.Item.DataBind("WorkSchedule_ID").ToString;
//int intPrimaryKey = Convert.ToInt32(strPrimaryKey);
strEvent = "<script language='javascript'>\r\n";
strEvent = strEvent + "popup('sow_notes.aspx?WorkSchedule_ID=" + strPrimaryKey;
strEvent = strEvent + "&survey_id=" + Request.QueryString["survey_id"].ToString();
strEvent = strEvent + "&sow_type_id=" + Request.QueryString["sow_type_id"].ToString();
strEvent = strEvent + "&surveytype_id=" + Request.QueryString["surveytype_id"].ToString();
strEvent = strEvent + "&property_id=" + Request.QueryString["property_id"].ToString() + "');\r\n";
strEvent = strEvent + "</script>";ViewState["sEvent"] = strEvent;
}
}
|
|
|
|
|
1. You should have posted this in the ASP .NET forum.
2. I don't know ASP .NET, but I think there are better ways of popping up a window.
3. Why are you initializing strPrimaryKey?
4. strPrimaryKey =e.Item.DataBind("WorkSchedule_ID").ToString; shouldn't even compile - ToString is a method, you are missing the parantheses.
5. Have you stepped through the code? What are you seeing there?
Cheers,
Vikram.
"If a trend is truly global, then that trend ought to be visible across ANY subset of that data" - fat_boy
|
|
|
|
|
Im Serializing this Object 'PersonNode'. It Serializing ok but the attribute 'name' is not coming through. Why would this be?
[Serializable]
public class PersonNode: List<child>
{
[XmlAttribute("name")]
public string name;
|
|
|
|
|
Hi All,
I have 4 project that have dependencies on each other.
I want to compile them all together - but i want to use some "make" file to do it because i need them to be compile in some const order.
I know that i can use the pre-Build option to set the compile order - but i prefer to do it by using some "make" file.
I don't know how to do it ( write the make file to this mission ).
Thanks for the help.
|
|
|
|
|
You could write the file yourself, but why since Visual Studio automatically detects project dependencies in the same solution and compiles them in the proper order.
Or, if you want to rearrange the dependencies yourself, just click the Project menu and pick "Project Dependencies" to set it up.
If you really want to write your own MSBuild files, I guess you can get an overview of it from this[^].
|
|
|
|
|
I have a problem:
if (radioButton1.Checked)
a.SubItems[1].BackColor = Color.Green;
else if (radioButton2.Checked)
a.SubItems[1].BackColor = Color.Orange;
else if (radioButton3.Checked)
a.SubItems[1].BackColor = Color.Red;
else if (radioButton4.Checked)
a.SubItems[1].BackColor = Color.White;
if i execute that code, the subitem don't change the color
how works??
|
|
|
|
|
|
I have a problem:
if (radioButton1.Checked)
a.SubItems[1].BackColor = Color.Green;
else if (radioButton2.Checked)
a.SubItems[1].BackColor = Color.Orange;
else if (radioButton3.Checked)
a.SubItems[1].BackColor = Color.Red;
else if (radioButton4.Checked)
a.SubItems[1].BackColor = Color.White;
|
|
|
|
|
Are you constipated? Are rabbits eating the cabbage in your garden? Are you on an airplane that has been hijacked? No? Then perhaps your problem is that you insufficiently described the "problematic" results you are seeing from running the above code, and will get NO help until you do. Be specific.
-Jeff
|
|
|
|