我爱编程

golang xlsx读写

2018-06-21  本文已影响0人  Feng_Sir
func TestRequest_LoadFromRemote2(t *testing.T) {

    xlsxfile2, err := xlsx.OpenFile("E:/apihub/1数据核查/信息核查数据.xlsx")
    if err != nil{
        fmt.Println( err)
        return
    }
    for _, sheet := range xlsxfile2.Sheets {
        for indexr, row := range sheet.Rows {
            if indexr < 2 {
                continue
            }
            //if indexr >= 3{
            //  break
            //}
            fmt.Print(fmt.Sprint(indexr)+"姓名:",strings.Trim(row.Cells[1].Value," ")," 身份证号:",strings.Trim(row.Cells[2].Value," "))
            request := Request{}
            request.IdCode = strings.Trim(row.Cells[2].Value," ")
            request.Name = strings.Trim(row.Cells[1].Value," ")
            ret, cost, e, remark := request.LoadFromRemote()
            fmt.Println(ret, cost, e, remark)
            row.AddCell().Value = fmt.Sprint(ret)
            fmt.Println()


        }
    }
    err = xlsxfile2.Save("E:/apihub/1数据核查/信息核查数据结果.xlsx")
    if err != nil{
        log.Println(err)
        return
    }

    fmt.Println("ok")

}
上一篇 下一篇

猜你喜欢

热点阅读