Click here to Skip to main content
15,916,693 members
Home / Discussions / C#
   

C#

 
GeneralRe: Byte Conversion Pin
spankyleo12325-Feb-10 4:37
spankyleo12325-Feb-10 4:37 
GeneralRe: Byte Conversion Pin
Saksida Bojan25-Feb-10 4:55
Saksida Bojan25-Feb-10 4:55 
GeneralRe: Byte Conversion Pin
spankyleo12325-Feb-10 4:59
spankyleo12325-Feb-10 4:59 
GeneralRe: Byte Conversion Pin
Richard MacCutchan25-Feb-10 5:15
mveRichard MacCutchan25-Feb-10 5:15 
QuestionWinforms Listview - Looking For Decent *Free* Control Pin
#realJSOP24-Feb-10 23:27
professional#realJSOP24-Feb-10 23:27 
AnswerRe: Winforms Listview - Looking For Decent *Free* Control Pin
Saksida Bojan25-Feb-10 0:02
Saksida Bojan25-Feb-10 0:02 
GeneralRe: Winforms Listview - Looking For Decent *Free* Control Pin
#realJSOP25-Feb-10 0:12
professional#realJSOP25-Feb-10 0:12 
QuestionC# - Fill a grid to Excelfile Pin
Mschauder24-Feb-10 22:37
Mschauder24-Feb-10 22:37 
Hey,

I want to create a .xlsx file based on data from a grid.

My problem: I have values like 01234 (starts with zero) exporting them make 1234 Dead | X| ... so, how can I export it with right format? Confused | :confused:

I fill the file with:

if (Excelpfad == "")
    return false;

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook newWorkbook = excelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Sheets excelSheets = newWorkbook.Worksheets;
string currentSheet = "Tabelle1";
Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(currentSheet);

for (int i = 0; i < UsingGrid.Cols; i++)
{
    for (int j = 0; j < UsingGrid.Rows; j++)
    {
        worksheet.Cells[j + 1, i + 1] = Convert.ToString(UsingGrid[j, i]);
    }
}

// Autosize cols
for (int iExcel = 0; iExcel < UsingGrid.Cols; iExcel++)
{
    ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[iExcel + 1, t]).ColumnWidth = UsingGrid.get_ColWidth(iExcel) * 0.13171875;
}

if (Excelpfad.Substring(Excelpfad.LastIndexOf(".")) == ".xls")
    worksheet.SaveAs(Excelpfad, Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
else if (Excelpfad.Substring(Excelpfad.LastIndexOf(".")) == ".xlsx")
    worksheet.SaveAs(Excelpfad, t, t, t, t, t, t, t, t, t);


and another question: how can I close that file correct?

I have:

newWorkbook.Close(true, n, n);
excelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet);


but the "EXCEL.EXE" process still run

thank you
AnswerRe: C# - Fill a grid to Excelfile Pin
Dan Mos25-Feb-10 5:48
Dan Mos25-Feb-10 5:48 
QuestionDate problem Pin
Mogamboo_Khush_Hua24-Feb-10 22:02
Mogamboo_Khush_Hua24-Feb-10 22:02 
AnswerRe: Date problem Pin
AspDotNetDev24-Feb-10 22:14
protectorAspDotNetDev24-Feb-10 22:14 
GeneralRe: Date problem Pin
Chetan Patel24-Feb-10 22:41
Chetan Patel24-Feb-10 22:41 
GeneralRe: Date problem Pin
AspDotNetDev24-Feb-10 22:57
protectorAspDotNetDev24-Feb-10 22:57 
AnswerRe: Date problem Pin
Luc Pattyn25-Feb-10 2:20
sitebuilderLuc Pattyn25-Feb-10 2:20 
QuestionERROR in service setup Pin
noamtzu0024-Feb-10 21:05
noamtzu0024-Feb-10 21:05 
AnswerMessage Closed Pin
24-Feb-10 21:28
stancrm24-Feb-10 21:28 
GeneralThankYou. Pin
noamtzu0025-Feb-10 1:12
noamtzu0025-Feb-10 1:12 
GeneralUninstalling a program Pin
NarVish24-Feb-10 20:36
NarVish24-Feb-10 20:36 
GeneralRe: Uninstalling a program Pin
Abhinav S25-Feb-10 1:48
Abhinav S25-Feb-10 1:48 
QuestionAd insertion technique Pin
booota24-Feb-10 20:22
booota24-Feb-10 20:22 
AnswerRe: Ad insertion technique Pin
AspDotNetDev24-Feb-10 21:28
protectorAspDotNetDev24-Feb-10 21:28 
QuestionRe: Ad insertion technique [modified] Pin
booota24-Feb-10 22:09
booota24-Feb-10 22:09 
QuestionC# and mobile phone ? Pin
Nematjon Rahmanov24-Feb-10 18:42
Nematjon Rahmanov24-Feb-10 18:42 
AnswerMessage Closed Pin
24-Feb-10 18:53
stancrm24-Feb-10 18:53 
GeneralRe: C# and mobile phone ? Pin
Nematjon Rahmanov24-Feb-10 19:00
Nematjon Rahmanov24-Feb-10 19:00 

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.