调整所有列和行的大小

时间:2019-07-17 17:25:07

标签: c# format

我需要格式化具有特定大小(例如3、12.75)的所有列和行。我有一些代码,但我需要帮助。谢谢。

我尝试这样: sheet.SetRowHeight(1,12.75); sheet.SetColumnWidth(1,3);

        Excel.Application xlApp;
        Excel.Workbook xlWorkBook;
        Excel.Worksheet xlWorkSheet;
        object misValue = System.Reflection.Missing.Value;
        Excel.Range chartRange;
        xlApp = new Excel.Application();
        xlWorkBook = xlApp.Workbooks.Add(misValue);
        xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
        xlWorkSheet.Cells[4, 2] = "";
        xlWorkSheet.Cells[4, 3] = "Value 1";
        xlWorkSheet.Cells[4, 4] = "Value 2";
        xlWorkSheet.Cells[4, 5] = "Value 3";

1 个答案:

答案 0 :(得分:0)

Workbook workbook = new Workbook();
workbook.LoadFromFile(@"Test.xls");

Worksheet sheet = workbook.Worksheets[0]; //Get 1st row

sheet.SetRowHeight(1, 20); //Set High
sheet.SetColumnWidth(1, 23); // Set Width