Click here to Skip to main content
15,890,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionPartial views(.ascx) in MVC in vs2008 or 2010 Pin
siva45513-Jul-11 16:47
siva45513-Jul-11 16:47 
AnswerRe: Partial views(.ascx) in MVC in vs2008 or 2010 Pin
Anurag Gandhi13-Jul-11 20:57
professionalAnurag Gandhi13-Jul-11 20:57 
QuestionProblem hosting a Silverlight movie properly in aspx and html Pin
Vimalsoft(Pty) Ltd13-Jul-11 8:30
professionalVimalsoft(Pty) Ltd13-Jul-11 8:30 
QuestionURL Rewriting ?? Pin
Sanjay Kunjam13-Jul-11 5:03
Sanjay Kunjam13-Jul-11 5:03 
AnswerRe: URL Rewriting ?? Pin
Not Active13-Jul-11 5:27
mentorNot Active13-Jul-11 5:27 
GeneralRe: URL Rewriting ?? Pin
Sanjay Kunjam13-Jul-11 5:36
Sanjay Kunjam13-Jul-11 5:36 
Questionexport dataset to excel without using htmltextwriter Pin
sujitdeshpande_1913-Jul-11 3:49
sujitdeshpande_1913-Jul-11 3:49 
QuestionImport Data From sql to Excel using Microsoft.Office.Interop Pin
sujitdeshpande_1912-Jul-11 22:18
sujitdeshpande_1912-Jul-11 22:18 
Hi

I am generating a excel file using Microsoft.Office.Interop.excel but the problem is the two excel file gets generated.one is with the file name that i had set. and other is with the name sheet1.xls. So please help me.
this is the code i am doing.+

public void excelgenerate(DataSet ds)
{
try
{

//Microsoft.Office.Interop.Excel.ApplicationClass excel = new ApplicationClass();

//excel.Application.Workbooks.Add(true);
Microsoft.Office.Interop.Excel.Application oAppln;
//declaring work book
Microsoft.Office.Interop.Excel.Workbook oWorkBook;
//declaring worksheet
Microsoft.Office.Interop.Excel.Worksheet oWorkSheet;
oAppln = new Microsoft.Office.Interop.Excel.Application();
oWorkBook = (Microsoft.Office.Interop.Excel.Workbook)(oAppln.Workbooks.Add(true));
//oWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)oWorkBook.ActiveSheet;
int i = 0;
foreach (System.Data.DataTable table in ds.Tables)
{
//oWorkSheet = new Microsoft.Office.Interop.Excel.Worksheet();

oWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)(oWorkBook.Worksheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing));
if (i == 0)
{
oWorkSheet.Name = "ActionPickListReport";
}
else
{
oWorkSheet.Name = "second";
}
oWorkSheet.Activate();


//oWorkBook.Worksheets.Add(null, null, 1, null);
//DataTable table = DATASETNAME.Tables[0];
int ColumnIndex = 0;

foreach (DataColumn col in table.Columns)
{
ColumnIndex++;

oWorkSheet.Cells[1, ColumnIndex] = col.ColumnName;
}
int rowIndex = 0;
foreach (DataRow row in table.Rows)
{
rowIndex++;
ColumnIndex = 0;
foreach (DataColumn col in table.Columns)
{
ColumnIndex++;
oWorkSheet.Cells[rowIndex + 1, ColumnIndex] = row[col.ColumnName].ToString();
}
}


// Worksheet worksheet = (Worksheet)oAppln.ActiveSheet;
//worksheet.Activate();
i++;
}

string fileName = "ActionPickReport.xls"; //System.Guid.NewGuid().ToString().Replace("-", "") + ".xls";
// string uploadfld = Server.MapPath("upload");
fileName = "C:\\Temp\\" + fileName;
//string strFile = "d://" + fileName;
//oWorkBook.Save();
oWorkBook.SaveAs(fileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, null, null, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, false, false,null, null,null);
//oWorkBook._SaveAs(fileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, "abc", "abc", false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, false, false, null, null);
oAppln.Quit();

}
catch (Exception ex)
{

}
finally { }
}
SuggestionRe: Import Data From sql to Excel using Microsoft.Office.Interop Pin
Shameel12-Jul-11 23:44
professionalShameel12-Jul-11 23:44 
QuestionValidating Email without the use of regular Expression ? Pin
Rameez Raja12-Jul-11 20:14
Rameez Raja12-Jul-11 20:14 
SuggestionRe: Validating Email without the use of regular Expression ? Pin
Blue_Boy12-Jul-11 21:07
Blue_Boy12-Jul-11 21:07 
AnswerEmail validation WebService Pin
David Mujica13-Jul-11 2:52
David Mujica13-Jul-11 2:52 
QuestionXML Deserialization Pin
indian14312-Jul-11 9:58
indian14312-Jul-11 9:58 
QuestionOnFocus server side event for textbox in datagrid Pin
minckle12-Jul-11 8:53
minckle12-Jul-11 8:53 
AnswerRe: OnFocus server side event for textbox in datagrid Pin
Viral Upadhyay12-Jul-11 23:36
Viral Upadhyay12-Jul-11 23:36 
Questionresolving class using interface using UNITY container to implement ioc pattern???? Pin
siva45512-Jul-11 7:43
siva45512-Jul-11 7:43 
QuestionRepeater Control - formatting columns problem Pin
Richard Blythe12-Jul-11 6:25
Richard Blythe12-Jul-11 6:25 
QuestionDeploying website on Windows XP computer? Pin
kbalias12-Jul-11 1:13
kbalias12-Jul-11 1:13 
AnswerRe: Deploying website on Windows XP computer? Pin
Pete O'Hanlon12-Jul-11 1:22
mvePete O'Hanlon12-Jul-11 1:22 
GeneralRe: Deploying website on Windows XP computer? Pin
kbalias12-Jul-11 19:44
kbalias12-Jul-11 19:44 
GeneralRe: Deploying website on Windows XP computer? Pin
Pete O'Hanlon12-Jul-11 23:25
mvePete O'Hanlon12-Jul-11 23:25 
QuestionRegex Pin
Morgs Morgan11-Jul-11 21:42
Morgs Morgan11-Jul-11 21:42 
AnswerRe: Regex Pin
Pete O'Hanlon11-Jul-11 21:50
mvePete O'Hanlon11-Jul-11 21:50 
GeneralRe: Regex Pin
Morgs Morgan11-Jul-11 22:06
Morgs Morgan11-Jul-11 22:06 
QuestionGridview merge cells with edit button Pin
C#Coudou11-Jul-11 15:11
C#Coudou11-Jul-11 15:11 

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.