• fpspread实现Excel导入


    private DataTable GetExcel(string filepach)
            {
                string str;
                FarPoint.Win.Spread.FpSpread fpSpread1 = new FarPoint.Win.Spread.FpSpread();

                try
                {
                    fpSpread1.OpenExcel(filepach);
                }
                catch
                {
                    string filepath1=Path.GetTempPath() + "//"+ Path.GetFileName(filepach);
                    File.Copy(filepach,filepath1) ;
                    fpSpread1.OpenExcel(filepath1);
                    File.Delete(filepath1);
                }
                DataTable dt = new DataTable();
                for (int k = 1; k <= fpSpread1.Sheets[0].GetLastNonEmptyColumn(FarPoint.Win.Spread.NonEmptyItemFlag.Data) + 1; k++)
                {
                    dt.Columns.Add("col" + k.ToString());
                }


                for (int i = 0; i < fpSpread1.Sheets[0].GetLastNonEmptyRow(FarPoint.Win.Spread.NonEmptyItemFlag.Data) + 1; i++)
                {
                    DataRow dr = dt.NewRow();
                    str = "";
                    for (int j = 0; j < fpSpread1.Sheets[0].GetLastNonEmptyColumn(FarPoint.Win.Spread.NonEmptyItemFlag.Data) + 1; j++)
                    {
                        str = str + fpSpread1.Sheets[0].Cells[i, j].Text;
                        dr[j] = fpSpread1.Sheets[0].Cells[i, j].Text;
                    }
                    if (str != "")
                        dt.Rows.Add(dr);

                }
                return dt;

  • 相关阅读:
    .NET core webApi 使用JWT验证签名
    sudo
    Mysql Error Code : 1436 Thread stack overrun
    Parallel World 4 – Parallel Task (1)
    SQLSTATE[HY000] [2002] Can't connect to local MySQL server
    Parallel World 3 – Parallel Task (2)
    Parallel World 5 – Concurrent Collections (1)
    Utime failed: Permission denied in Smarty/sysplugins/smarty_internal_template.php on line xxx
    Add Reference
    Javascript Tips
  • 原文地址:https://www.cnblogs.com/laojiefang/p/2323777.html
Copyright © 2020-2023  润新知