This is a migrated thread and some comments may be shown as answers.

MVC Grid Export works for Excel 2007 but not Excel 2003

1 Answer 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arnold Smith
Top achievements
Rank 1
Arnold Smith asked on 11 Feb 2011, 10:01 PM
Hi Experts,

I am using the 'Export to CSV' feature for several grids in an application and it works for Excel 2007. However, with Excel 2003 there is an issue. Although the column headers appear within individual cells (Columns A, B C etc...), the rows beneath them do not. All rows appear bunched up within Column A. In Excel 2007, the rows appear underneath their individual headers.

Is Excel 2003 supported or can I modify the code, as shown below, so that it is compatible with Excel 2003?

writer.Write(

"Account Id,");

 

 writer.Write(

"Admit Date,");

 

 writer.Write(

"Discharge Date,");

 

 writer.Write(

"Attending,");

 

 writer.Write(

"ClinicCode");

 

 writer.WriteLine();

 

foreach (GetMPIDataByMRNResult x in mpiData)

 

 {

 writer.Write(x.AccountId);

 writer.Write(

",");

 

 writer.Write(

"\"");

 

 writer.Write(

String.Format("{0:d}", x.AdmitDate));

 

 writer.Write(

"\"");

 

 writer.Write(

",");

 

 writer.Write(

"\"");

 

 writer.Write(

String.Format("{0:d}", x.DischargeDate));

 

 writer.Write(

"\"");

 

 writer.Write(

",");

 

 writer.Write(

"\"");

 

 writer.Write(x.Attending);

 writer.Write(

"\"");

 

 writer.Write(

",");

 

 writer.Write(x.ClinicCode);

 writer.WriteLine();

 }

 writer.Flush();

 output.Position = 0;

 

string fileName = "MPIDataReport_" + MRN + ".csv";

 

 

return File(output, "text/comma-separated-values", fileName);

 

 

Thanks!

Arnold Smith

1 Answer, 1 is accepted

Sort by
0
Arnold Smith
Top achievements
Rank 1
answered on 14 Mar 2011, 04:14 PM
Got it figured out. It's an issue with the configuration of Excel on the users' machines.
Tags
Grid
Asked by
Arnold Smith
Top achievements
Rank 1
Answers by
Arnold Smith
Top achievements
Rank 1
Share this question
or