List Info

Thread: C-Sharp (C#) Group: How to output the result to Notepad from Win form application using C#




C-Sharp (C#) Group: How to output the result to Notepad from Win form application using C#
user name
2006-08-17 16:23:11
We are developing a window form application with C#, and
part of its
function is to output the calculation results to MS Excel
sheet. In
order to handle the drastic case, we decided to modified
this function
to let it output the results to Notepad if MS Excel is
detected not
installed on the end user's machine (Nowsday it is really
hard to find
such machine). Now I can open a new session of Notepad from
the
application using the shell function, but I am not quite
confident of
how to write the results into this newly opened Notepad
session. Does
any one know if C# provide such built-in functionality to
handle the
Notepad or Wordpad as it is handling the Excel?

For example, I can write something like the following to
export to
Excel

private void cmdExport_Click(object sender, System.EventArgs
e)
{
             Microsoft.Office.Interop.Excel.Application
excel = null;
             Microsoft.Office.Interop.Excel.Workbook wb =
null;
             Microsoft.Office.Interop.Excel.Worksheet ws =
null;
             Microsoft.Office.Interop.Excel.Range rng =
null;
             object  missing  = Type.Missing;

      try
      {
	excel = new Microsoft.Office.Interop.Excel.Application();
	wb = excel.Workbooks.Add(missing);
	ws =
(Microsoft.Office.Interop.Excel.Worksheet)wb.ActiveSheet;

	//write the border for the dataset
                rng = ws.get_Range("B2",
"F26");
	rng.BorderAround(missing, XlBorderWeight.xlThick,
XlColorIndex.xlColorIndexAutomatic, missing);

	//Title line of the sheet
	rng = ws.get_Range("B2", "F2");
	rng.Cells.MergeCells = 5;
	rng.Font.Bold = true;
	rng.Font.Size = 16;
	rng.Font.Name = "arial";
	rng.Font.Italic = true;
	rng.Font.Color = System.Drawing.Color.Blue.ToArgb();
	rng.VerticalAlignment = XlVAlign.xlVAlignBottom;
	rng.HorizontalAlignment = XlHAlign.xlHAlignCenter;
	rng.BorderAround(missing, XlBorderWeight.xlThick,
XlColorIndex.xlColorIndexAutomatic, missing);
	rng.Value2 = "Sand Bed Headcut and Tailcut
Profiles";


so what I am asking is that 'Does C# provide the similar
thing to
handle the output to Notepad or Wordpad?'

Thanks in advance for any help or suggestions.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: How to output the result to Notepad from Win form application using C#
user name
2006-08-17 16:52:43
I would write a file first to %USERPROFILE%\Local
Settings\Temp\ then this
code to open the file in their default text editor:

using System.Diagnostics;

....

ProcessStartInfo psi = new ProcessStartInfo(
	String.Format("\Local
Settings\Temp\the_file.txt",
Environment.GetEnvironmentVariable("USERPROFILE"
)));
psi.UseShellExecute = true;
Process.Start(psi);


Doing this would allow them save it wherever and the temp
file will be
erased from the temp folder when they use the disk cleanup
tool to cleanup
temporary files (I think, I would verify it).


Hope this helps,
J.P.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )