for (int i = rowIndex+1; i <= sheet.LastRowNum; i++)
{
NPOI.SS.UserModel.IRow row = sheet.GetRow(i);
if (row == null) continue;
int firstCellNum = row.FirstCellNum;
int lastCellNum = row.LastCellNum;
if (firstCellNum == lastCellNum) continue;
for (int ji = firstCellNum; ji < lastCellNum; ji++) //LastRowNum 是当前表的总行数
{
if (!dt.Columns.Contains(row.GetCell(ji).ToString()))
{
dt.Columns.Add(row.GetCell(ji).StringCellValue, typeof(string));
}
if (row != null && row.GetCell(0) != null)
{
if (row.GetCell(0).ToString() != "")
{
string InvoiceNo = row.GetCell(0).ToString();
string CNo = row.GetCell(1).ToString();
string PartNo = row.GetCell(2).ToString();
string MurataType = row.GetCell(3).ToString();
string Country = row.GetCell(4).ToString();
string HsCode = row.GetCell(5).ToString();
string ChineseDescription = row.GetCell(6).ToString();
string CardNo = row.GetCell(7).ToString();
string CustomerPo = row.GetCell(8).ToString();
string Qty = row.GetCell(9).ToString();
string Unit = row.GetCell(10).ToString();
string GrossWeight = row.GetCell(11).ToString();
string NetWeight = row.GetCell(12).ToString();
string SalesPrice = row.GetCell(13).ToString();
ExcuSql += "INSERT INTO mflex_spl_data( invoice_no, c_no, part_no, murata_type, country, hs_code, chinese_description, card_no, customer_po, qty, unit, gross_weight, net_weight, sales_price,file_name,create_user,create_time) " +
"VALUES( '" + InvoiceNo + "','" + CNo + "','" + PartNo + "','" + MurataType + "','" + Country + "','" + HsCode + "','" + ChineseDescription + "','" + CardNo + "','" + CustomerPo + "','" + Qty + "','" + Unit + "','" + GrossWeight + "','" + NetWeight + "','" + SalesPrice + "','" + FileName + "','edi',now());";
}
}