留言薄

一直相信,被人记得也是一种幸福

你想说些什么呢?就在这里回复吧~ 欢迎灌水,来者不拒!

170 条评论

:wink: :twisted: :roll: :oops: :evil: :?: :-| :-P :-D :) :( :!: 8)
昵称
  1. 森纯博客

    留个脚印

  2. andy123

    public static bool ExportExcel(System.Data.DataTable dt, string fileName)
    {
    bool Msg = false;
    //Excel intialiazation
    object Nothing = System.Reflection.Missing.Value;
    Application ExcelApp = new Application();
    ExcelApp.Visible = false;
    Workbook workBook = ExcelApp.Workbooks.Add(Nothing);
    Worksheet worksheet = (Worksheet)workBook.Sheets[1];
    worksheet.Name = “Work”;

    try
    {
    //import columns
    for (int j = 0; j < dt.Columns.Count; j++)
    {
    worksheet.Cells[1, j+1] = dt.Columns[j].ColumnName;
    }

    //import contents
    for (int i = 0; i < dt.Rows.Count; i++)
    {
    for (int j = 0; j < dt.Columns.Count; j++)
    {
    worksheet.Cells[i+2, j+1] = dt.Rows[i][j];
    }
    }
    Msg = true;
    }
    catch (Exception e)
    {
    Console.WriteLine(e.Message);
    }

    //Excel Termination
    worksheet.SaveAs(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing);
    workBook.Close(false, Type.Missing, Type.Missing);
    ExcelApp.Quit();

    return Msg;
    }

  3. 齐发

    博主你好

  4. 钓鱼

    看懂了?

  5. popoo

    :evil: :-| :?:

  6. ff

    ddd

  7. 不点儿

    :-P :-P 学的不仅时技术,更是梦想~~喜欢 :(

    1. 那么美

  8. 145

    53

  9. 文案怎么写

    博主的文笔很不错,仰慕已久,特来拜会。若能有幸能得到博主的回访,必将欣喜若狂。