1

如何使用c#删除excel表格中的删除行?

我试过这个:

{
    Excel.Application app = new Excel.Application();
    Excel.Workbook workbook = app.Workbooks.Open("D:/Excel.xlsx", Type.Missing, Type.Missing, 
                                                  Type.Missing, Type.Missing, Type.Missing, 
                                                  Type.Missing, Type.Missing, Type.Missing, 
                                                  Type.Missing, Type.Missing, Type.Missing, 
                                                  Type.Missing, Type.Missing, Type.Missing);

    Excel.Worksheet ws = (Excel.Worksheet)app.Sheets["Production_2013"];
    Excel.Range range = ws.get_Range("A5", "T10");
    string clean_string = CleanStrikethroughChars(range);
}

string CleanStrikethroughChars(Excel.Range range) {
    string s = "";
    int char_index = 1;
    int length = range.Cells.Value2.ToString().Length;

    while (char_index < length) {
        if ((bool)range.Cells.get_Characters(char_index, 1).Font.Strikethrough) {
            s += range.Cells.get_Characters(char_index, 1).Text;
            char_index++;
        }
    }
    return s;
4

1 回答 1

0

确定如何使用 Excel 互操作操作的最佳方法之一是在 Excel 中创建预期操作的宏,然后查看生成的 VBA 代码。这可能会提供有关如何执行所需操作的提示。

于 2013-06-25T13:30:09.193 回答