日期:2014-05-20 浏览次数:20893 次
 for (int colIndex = 1; colIndex < workSheet.UsedRange.Cells.Columns.Count; colIndex++)//循环读取Excel列
            {
                ColNum = convertToCharacter(colIndex);
                string colomtext = "";
                if (workSheet.get_Range(ColNum + "3", Missing.Value).Value2 != null)
                {
                   [color=#FF0000] colomtext = workSheet.get_Range(ColNum + "3", Missing.Value).Value2.ToString(); //获[/color]取字母列名称
                }
                switch (colomtext)//
                {
                    case "&名称":
                        nameIndex = colIndex;
                        workSheet.get_Range(ColNum + "3", Missing.Value).Value2 = "名称";
                        break;
                    case "&件数":
                        numIndex = colIndex;
                        workSheet.get_Range(ColNum + "3", Missing.Value).Value2 = "件数";
                        break;
                    case "&数量":
                        qtyIndex = colIndex;
                        workSheet.get_Range(ColNum + "3", Missing.Value).Value2 = "数量";
                        break;
                    case "&单价":
                        priceIdex = colIndex;
                        workSheet.get_Range(ColNum + "3", Missing.Value).Value2 = "单价";
                        break;
                    case "&金额":
                        sumIndex = colIndex;
                        workSheet.get_Range(ColNum + "3", Missing.Value).Value2 = "金额";
                        break;
                }
            }
            //获取顾客名称
            if (cbxCustomer.Text != null)
            {
                workSheet.Cells[2, 2] = this.cbxCustomer.Text.ToString();
            }