gpt4 book ai didi

c# - 以编程方式更改 Excel 行或列的高度

转载 作者:行者123 更新时间:2023-11-30 14:36:56 25 4
gpt4 key购买 nike

可能很简单。如何更改行或列的高度?

 xlApp = new Excel.Application();
xlApp.Visible = true;
xlApp.DisplayAlerts = false;
Excel.Workbooks xlWorkBooks = xlApp.Workbooks;
xlWorkBook = xlWorkBooks.Open(directoryPath + "\\" + fileName, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);

xlWorkSheets = xlWorkBook.Worksheets; //Get all the sheets in the workbook
xlWorkSheet = (Excel.Worksheet)xlWorkSheets.get_Item("Sheet1"); //Get the allready exists sheet
Excel.Range range = xlWorkSheet.UsedRange;
Excel.Range chartRange;

int colCount = range.Columns.Count;
int rowCount = range.Rows.Count;

xlWorkSheet.Cells[rowCount + 5, 1] = "Name and surname";
chartRange = xlWorkSheet.get_Range("a" + (rowCount + 5), "e" + (rowCount + 5));
chartRange.Font.Bold = true;

xlWorkBook.SaveAs(fileName, Excel.XlFileFormat.xlOpenXMLWorkbook, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(misValue, misValue, misValue);
xlWorkSheet = null;
xlWorkBook = null;
xlApp.Quit();

GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();

尝试使用 xlWorkSheet.UsedRange.EntireRow.Height = value; 但它不起作用。 autoFit() 正在运行,但我想使用我的值。

最佳答案

关于c# - 以编程方式更改 Excel 行或列的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9922720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com