Click here to Skip to main content
15,893,161 members
Home / Discussions / C#
   

C#

 
AnswerRe: Looking for simple graph library for C# windows console app Pin
OriginalGriff14-Nov-14 4:47
mveOriginalGriff14-Nov-14 4:47 
AnswerRe: Looking for simple graph library for C# windows console app Pin
jsundownr14-Nov-14 5:19
jsundownr14-Nov-14 5:19 
AnswerRe: Looking for simple graph library for C# windows console app Pin
BillWoodruff14-Nov-14 5:55
professionalBillWoodruff14-Nov-14 5:55 
GeneralRe: Looking for simple graph library for C# windows console app Pin
jsundownr14-Nov-14 6:09
jsundownr14-Nov-14 6:09 
GeneralRe: Looking for simple graph library for C# windows console app Pin
BillWoodruff14-Nov-14 7:12
professionalBillWoodruff14-Nov-14 7:12 
GeneralRe: Looking for simple graph library for C# windows console app Pin
jsundownr14-Nov-14 7:32
jsundownr14-Nov-14 7:32 
AnswerRe: Looking for simple graph library for C# windows console app Pin
Gerry Schmitz14-Nov-14 10:28
mveGerry Schmitz14-Nov-14 10:28 
GeneralRe: Looking for simple graph library for C# windows console app Pin
jsundownr14-Nov-14 13:52
jsundownr14-Nov-14 13:52 
QuestionExport data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Member 1113495413-Nov-14 23:28
Member 1113495413-Nov-14 23:28 
AnswerRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Eddy Vluggen14-Nov-14 0:25
professionalEddy Vluggen14-Nov-14 0:25 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Member 1113495417-Nov-14 23:11
Member 1113495417-Nov-14 23:11 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Pete O'Hanlon17-Nov-14 23:52
mvePete O'Hanlon17-Nov-14 23:52 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Eddy Vluggen18-Nov-14 0:32
professionalEddy Vluggen18-Nov-14 0:32 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Member 1113495418-Nov-14 21:54
Member 1113495418-Nov-14 21:54 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Eddy Vluggen19-Nov-14 2:58
professionalEddy Vluggen19-Nov-14 2:58 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Member 1113495419-Nov-14 23:30
Member 1113495419-Nov-14 23:30 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Eddy Vluggen20-Nov-14 5:11
professionalEddy Vluggen20-Nov-14 5:11 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Member 1113495421-Nov-14 22:28
Member 1113495421-Nov-14 22:28 
QuestionRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
Eddy Vluggen22-Nov-14 3:57
professionalEddy Vluggen22-Nov-14 3:57 
GeneralRe: Export data from Excel (xls file) to Sql data table by clicking on export button (c#) Pin
PIEBALDconsult22-Nov-14 4:55
mvePIEBALDconsult22-Nov-14 4:55 
QuestionHow To Increase Width Excel Cell Size When I Export Excel File Pin
Nishant.Chauhan8013-Nov-14 22:11
Nishant.Chauhan8013-Nov-14 22:11 
When i export excel file with increase cell width because my data Not show completely into cell

How To implement In this code To Increase cell Width in cell File


My Export Excel Code Following :-


public ActionResult ExportToExcel(int MID)
{
MModule objModule = new MModule();
objModule.LoadModule(MID);
DatabaseObject objData = new DatabaseObject();
string file = DateTime.Now.Ticks + "_" + objModule.Title + ".xlsx";
System.IO.File.Copy(Server.MapPath("/Excel/Export/template.xlsx"), Server.MapPath("/Excel/Export/" + file));
string filename = Server.MapPath("/Excel/Export/" + file);
objData.Query = "SELECT * FROM " + objModule.TableName + "";
DataTable dtReport = objData.GetTable();
System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + ";Mode=ReadWrite;Extended Properties=\"Excel 12.0 Xml;Readonly=False;IMEX=0;\"");

con.Open();
System.Data.OleDb.OleDbCommand cmd = con.CreateCommand();
string tableString = "";
string ColString = "";
for (int i = 0; i < dtReport.Columns.Count; i++)
{
tableString += "[" + dtReport.Columns[i].Caption + "] varchar(255),";
ColString += "[" + dtReport.Columns[i].Caption + "],";
}
tableString = tableString.Substring(0, tableString.Length - 1);
try
{
ColString = ColString.Substring(0, ColString.Length - 1);

//***************** Create Excel Sheet Table *********************//

cmd.CommandText = "CREATE TABLE ["+ objModule.Title +"] ( " + tableString + ");";
cmd.ExecuteNonQuery();

string ValString = "";
for (int j = 0; j < dtReport.Rows.Count; j++)
{
ValString = "";
for (int i = 0; i < dtReport.Columns.Count; i++)
{
ValString += "'" + dtReport.Rows[j][i] + "',";
}
ValString = ValString.Substring(0, ValString.Length - 1);
cmd.CommandText = "Insert Into ["+ objModule.Title +"] (" + ColString + ") Values (" + ValString + ");";
cmd.ExecuteNonQuery();
}


cmd.Dispose();
con.Dispose();
con.Close();

Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workbook = excelApplication.Workbooks.Open(filename,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);

excelApplication.DisplayAlerts = false;
((Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1]).Delete();
workbook.Close(true, filename, null);
excelApplication.DisplayAlerts = true;
}
catch (Exception ex)
{
}
//return File(filename, "application/msexcel");
return File(filename, "application/x-excel", DateTime.Now.Ticks + "_Report.xlsx");
}
AnswerRe: How To Increase Width Excel Cell Size When I Export Excel File Pin
Dave Kreskowiak14-Nov-14 2:15
mveDave Kreskowiak14-Nov-14 2:15 
QuestionHow to create Data recovery application using c#.net windows form Pin
Srikanth5913-Nov-14 18:27
Srikanth5913-Nov-14 18:27 
AnswerRe: How to create Data recovery application using c#.net windows form Pin
Dave Kreskowiak13-Nov-14 18:32
mveDave Kreskowiak13-Nov-14 18:32 
RantRe: How to create Data recovery application using c#.net windows form Pin
Richard Deeming14-Nov-14 2:15
mveRichard Deeming14-Nov-14 2:15 

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.