panda728 / DataGridViewDump

Output the contents of a DataGridView to an Excel file. Supports reordering of data and replacement of columns.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataGridViewDump

Output the contents of a DataGridView to an Excel file. Supports reordering of data and replacement of columns.

Sample

image

image

library

https://github.com/panda728/FakeExcelSerializer

Excel file creation process

    saveFileDialog1.FileName = "datagridviewdump.xlsx";
    if (saveFileDialog1.ShowDialog() != DialogResult.OK)
        return;

    dataGridView1.ToExcelFile(saveFileDialog1.FileName);

Overview

DumpExcelHelper.cs

var newConfig = ExcelSerializerOptions.Default with
{
    Provider = _dataGridViewExcelProvider,
    CultureInfo = CultureInfo.CurrentCulture,
    HasHeaderRecord = hasHeaderRecord || (headerTitles?.Any() ?? false),
    HeaderTitles = headerTitles ?? Array.Empty<string>(),
    AutoFitColumns = autoFitColumns,
    NumberFormat = "#,##0.000;[Red]\\-#,##0.000",
};
ExcelSerializer.ToFile(value, fileName, newConfig);

License

This library is licensed under the MIT License.

About

Output the contents of a DataGridView to an Excel file. Supports reordering of data and replacement of columns.

License:MIT License


Languages

Language:C# 100.0%