Click here to Skip to main content
15,917,795 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Find Client Network is unplugged Pin
sindhutiwari4-Jan-08 21:29
sindhutiwari4-Jan-08 21:29 
GeneralRe: How to Find Client Network is unplugged Pin
mav.northwind5-Jan-08 0:14
mav.northwind5-Jan-08 0:14 
GeneralRe: How to Find Client Network is unplugged Pin
sindhutiwari5-Jan-08 0:57
sindhutiwari5-Jan-08 0:57 
GeneralRe: How to Find Client Network is unplugged Pin
mav.northwind5-Jan-08 2:25
mav.northwind5-Jan-08 2:25 
AnswerRe: How to Find Client Network cable is unplugged or plugged in Pin
Patrick Etc.5-Jan-08 3:10
Patrick Etc.5-Jan-08 3:10 
GeneralRe: How to Find Client Network cable is unplugged or plugged in Pin
sindhutiwari6-Jan-08 20:45
sindhutiwari6-Jan-08 20:45 
GeneralRe: How to Find Client Network cable is unplugged or plugged in Pin
Patrick Etc.7-Jan-08 4:59
Patrick Etc.7-Jan-08 4:59 
GeneralDisplaying CSV in Excel from C# code. Pin
yoavyoavyoav4-Jan-08 21:01
yoavyoavyoav4-Jan-08 21:01 
Hi There ,

I have an application that creates a csv file and I want it to display it in excel after creation.

I've used to following code - which works well :




using ExcelInterop = Microsoft.Office.Interop.Excel;<br />
 <br />
  ExcelInterop._Worksheet ExcelWorkSheet; //represents the resulting worksheet.<br />
 <br />
            Microsoft.Office.Interop.Excel.Application excelApp = null;<br />
            try<br />
            {<br />
                excelApp = new ExcelInterop.ApplicationClass();<br />
 <br />
               <br />
                excelApp.Visible = true;<br />
 <br />
                string path = txtOutputPath.Text; //full file path is given.<br />
                excelApp.Workbooks.Open(path, 0, false, 2, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindow  s, "", true, false, 0, true, false, false);<br />
                ExcelWorkSheet = (ExcelInterop._Worksheet)(excelApp.ActiveWorkbook.  ActiveSheet);<br />
                ExcelWorkSheet.Columns.AutoFit();<br />
                ExcelWorkSheet.Columns.HorizontalAlignment = ExcelInterop.XlHAlign.xlHAlignLeft; //aligns values to the left.<br />
                ExcelWorkSheet._DisplayRightToLeft = 0; //makes the excel to display as left-to-right.<br />
            }<br />
            catch (Exception ex) //Used to catch exception of type "System.Runtime.InteropServices.COMException"<br />
            {<br />
                if (excelApp != null)<br />
                    excelApp.Quit();<br />
                MessageBox.Show(ex.Message);<br />
            }


(The code above is just a segment)

The thing is - my CSV file contains some fields with long numbers. I want this numbers to be displayed as text (WYSIWYG) - but Excel chagnes them - for eg. : 909490266168 -----> 9.0949E+11


I want to add something to my code that'll set the format of all cells to be "Text" (So everything will be displayed just as it is in the CSV file - not altering anything).


I tried : ExcelWorkSheet.Cells.NumberFormat = "Text" but this did not work properly and messed up some Date cells.


I'm not so familier with Excel Programming , So help will be appreciated. Thanks in advance.
GeneralRe: Displaying CSV in Excel from C# code. Pin
PIEBALDconsult5-Jan-08 4:39
mvePIEBALDconsult5-Jan-08 4:39 
GeneralAdding Tooltip in DropDownList ... Pin
Dev Motiramani4-Jan-08 20:24
Dev Motiramani4-Jan-08 20:24 
Questionattendance time application Pin
Member 41949064-Jan-08 19:22
Member 41949064-Jan-08 19:22 
GeneralRe: attendance time application Pin
Abhijit Jana4-Jan-08 22:23
professionalAbhijit Jana4-Jan-08 22:23 
GeneralRe: attendance time application Pin
PIEBALDconsult5-Jan-08 4:41
mvePIEBALDconsult5-Jan-08 4:41 
GeneralProblem in treeView Pin
chanzeb4-Jan-08 19:16
chanzeb4-Jan-08 19:16 
GeneralTry to display the IP address, but failed.... Pin
DotNet4-Jan-08 17:06
DotNet4-Jan-08 17:06 
GeneralRe: Try to display the IP address, but failed.... Pin
Guffa5-Jan-08 2:26
Guffa5-Jan-08 2:26 
GeneralRe: Try to display the IP address, but failed.... Pin
DotNet5-Jan-08 2:33
DotNet5-Jan-08 2:33 
GeneralRe: Try to display the IP address, but failed.... Pin
Guffa5-Jan-08 2:41
Guffa5-Jan-08 2:41 
GeneralRe: Try to display the IP address, but failed.... Pin
DotNet5-Jan-08 4:04
DotNet5-Jan-08 4:04 
GeneralSMS PDU Conversion Pin
Nukumaar4-Jan-08 16:22
Nukumaar4-Jan-08 16:22 
GeneralDirection for noob [never mind] Pin
Wes Aday4-Jan-08 15:56
professionalWes Aday4-Jan-08 15:56 
GeneralRe: Direction for noob Pin
Patrick Etc.4-Jan-08 17:03
Patrick Etc.4-Jan-08 17:03 
GeneralRe: Direction for noob Pin
Wes Aday4-Jan-08 17:21
professionalWes Aday4-Jan-08 17:21 
GeneralRe: Direction for noob Pin
Patrick Etc.4-Jan-08 17:28
Patrick Etc.4-Jan-08 17:28 
GeneralRe: Direction for noob Pin
Wes Aday4-Jan-08 17:41
professionalWes Aday4-Jan-08 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.