Click here to Skip to main content
14,427,455 members
   

C#

 
Questionscrols in grid column Pin
Nilish22-Jul-08 1:06
MemberNilish22-Jul-08 1:06 
AnswerRe: scrols in grid column Pin
stancrm22-Jul-08 2:53
Memberstancrm22-Jul-08 2:53 
Questionweb site needs certificate Pin
George_George22-Jul-08 0:28
MemberGeorge_George22-Jul-08 0:28 
AnswerRe: web site needs certificate Pin
leppie22-Jul-08 6:29
Memberleppie22-Jul-08 6:29 
GeneralRe: web site needs certificate Pin
George_George27-Jul-08 2:31
MemberGeorge_George27-Jul-08 2:31 
QuestionCreate Pop Server Pin
kathiresanmoorthy21-Jul-08 23:33
Memberkathiresanmoorthy21-Jul-08 23:33 
GeneralRe: Create Pop Server Pin
Guffa22-Jul-08 0:41
MemberGuffa22-Jul-08 0:41 
QuestionCreating different excel file and exporting datatbles in that Pin
Member 387988121-Jul-08 22:24
MemberMember 387988121-Jul-08 22:24 
Hi i am having lot of tables in my dataset...,
Based on datatable first row first cell i am creating folder and creating excel file and export my datatble to that excel file...,

Everything is going on well...,

But during this perios lot of alert msg coming from excel side:
Do you want to save changes in "Book 61"
Like this upt o Book 73 or 73...,
Its coming on each folder creation time...,


This is my code:

for (int i = 0; i < DS.Tables.Count - 1; i++)
{
oXL = new Microsoft.Office.Interop.Excel.Application();
oWB = oXL.Workbooks.Add(System.Reflection.Missing.Value);
oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;
oRng = oSheet.Cells;
oSheet.Activate();
try
{
foreach (DataRow dr1 in DS.Tables[i].Rows)
{
foreach (DataRow dr2 in DS.Tables[i + 1].Rows)
{
if (dr1["MID"].ToString() == dr2["MID"].ToString())
{
DirectoryInfo dr = new DirectoryInfo("C:\\Test\\" + dr1["MID"].ToString() + @"\");
if (!dr.Exists)
{
dr.Create();
System.Data.DataTable dtToExport = DS.Tables[i];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
else
{
System.Data.DataTable dtToExport = DS.Tables[i + 1];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
}

else
{
DirectoryInfo dr = new DirectoryInfo("C:\\Test\\" + dr2["MID"].ToString() + @"\");
if (!dr.Exists)
{
dr.Create();
System.Data.DataTable dtToExport = DS.Tables[i + 1];
//oSheet.Activate();
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls");

if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
else
{
System.Data.DataTable dtToExport = DS.Tables[i];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
}
}
}
}
catch (Exception theException)
{
MessageBox.Show(theException.ToString(), "Error");
}
}

Plz guideme whats wrong in that?

Thanks & Regards,
NeW OnE,
please don't forget to vote on the post

AnswerRe: Creating different excel file and exporting datatbles in that Pin
Ashfield22-Jul-08 2:20
MemberAshfield22-Jul-08 2:20 
QuestionFocus in Dialog in Setup Project Pin
Sifar - 021-Jul-08 22:09
MemberSifar - 021-Jul-08 22:09 
QuestionUsing Unsafe code Pin
sumit703421-Jul-08 21:53
Membersumit703421-Jul-08 21:53 
AnswerRe: Using Unsafe code Pin
stancrm21-Jul-08 22:14
Memberstancrm21-Jul-08 22:14 
GeneralRe: Using Unsafe code Pin
sumit703421-Jul-08 22:36
Membersumit703421-Jul-08 22:36 
QuestionBitmap to ByteArray Conversion...? Pin
DeepOceans21-Jul-08 20:59
MemberDeepOceans21-Jul-08 20:59 
AnswerRe: Bitmap to ByteArray Conversion...? Pin
stancrm21-Jul-08 22:16
Memberstancrm21-Jul-08 22:16 
AnswerRe: Bitmap to ByteArray Conversion...? Pin
Guffa22-Jul-08 0:50
MemberGuffa22-Jul-08 0:50 
AnswerRe: Bitmap to ByteArray Conversion...? Pin
Anthony Mushrow22-Jul-08 1:35
professionalAnthony Mushrow22-Jul-08 1:35 
AnswerRe: Bitmap to ByteArray Conversion...? Pin
Jacek Gajek22-Jul-08 1:40
MemberJacek Gajek22-Jul-08 1:40 
Questionpop server connection Pin
kathiresanmoorthy21-Jul-08 20:35
Memberkathiresanmoorthy21-Jul-08 20:35 
RantRe: pop server connection Pin
Guffa22-Jul-08 0:52
MemberGuffa22-Jul-08 0:52 
Questionretreving the gridview row in color from sqlserver using boundfields Pin
santosh04221-Jul-08 19:53
Membersantosh04221-Jul-08 19:53 
AnswerRe: retreving the gridview row in color from sqlserver using boundfields Pin
Srishti Mathur21-Jul-08 20:48
MemberSrishti Mathur21-Jul-08 20:48 
Questionhow to get domain part from URL Pin
George_George21-Jul-08 18:22
MemberGeorge_George21-Jul-08 18:22 
AnswerRe: how to get domain part from URL Pin
Bert delaVega21-Jul-08 18:40
MemberBert delaVega21-Jul-08 18:40 
GeneralRe: how to get domain part from URL Pin
George_George21-Jul-08 19:14
MemberGeorge_George21-Jul-08 19:14 

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.