Helle guy,我的excel输出不是我想要的
我想创建一个自定义的excel输出。但我的事情是它不给我输出。一旦代码达到if (fline.Designator == null)
其显示我的错误.. 请看看我的问题,并给我一个解决方案。
代码: -
private void button1_Click(object sender, EventArgs e)
{
string[] strLines = System.IO.File.ReadAllLines(textBox1.Text);
string line = string.Empty;
string CarouselName = enter.Text;
int iCarousel = 0;
char seperator = '\t';
SortedDictionary<string, ExcelData> lstExcel = new SortedDictionary<string, ExcelData>();
ExcelData fline = null;
for (int i = 0; i < strLines.Length; i++)
{
line = RemoveWhiteSpace(strLines[i]).Trim();
if (line.Length == 0)
continue;
string[] cells = line.Replace("\"", "").Split(seperator);
if (i > 0)
{
if (!lstExcel.ContainsKey(cells[1].Replace(" ", "_")))
{
fline = new ExcelData();
lstExcel.Add(cells[1].Replace(" ", "_"), fline);
fline.Footprint = cells[2].Replace(" ", "_");
fline.Comment = cells[1].Replace(" ", "_");
iCarousel++;
if (iCarousel > 45)
iCarousel = 1;
fline.Location = CarouselName;
}
else
{
fline = lstExcel[cells[1].Replace(" ", "_")];
}
fline.SrNo++;
fline.Total++;
}
if (fline.Designator == null)// here its showing the error..
// i don't know why its the code is incorrect. please help me out!!
fline.Designator = new List<string>();
fline.Designator.Add(cells[0].Replace(" ", "_"));
}
ExportInExcel(lstExcel, @"C:\Users\Stacy\Desktop\myExcel.xls");
System.Windows.Forms.Application.Exit();
}
什么是错误信息? – grovesNL 2014-11-07 03:16:13
@grovesNL https://imageshack.com/i/f0tIFW6Dj请给我一个错误 – 2014-11-07 03:17:50