开发者

Programmatically alter an Excel sheet's row height

开发者 https://www.devze.com 2023-02-10 14:19 出处:网络
How can I alter the row heights of all m开发者_如何转开发y non empty rows in my EXCEL sheet? Thanks in advance,

How can I alter the row heights of all m开发者_如何转开发y non empty rows in my EXCEL sheet? Thanks in advance, w.


...EntireRow.RowHeight = value;


Seems to be "Range.RowHeight" to modify the range's row height. http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.namedrange.rowheight%28v=vs.80%29.aspx


I use the following:

        xlWorkSheet.Rows.RowHeight = height;
        xlWorkSheet.StandardWidth = width;


MySheet.UsedRange.EntireRow.Height = value;


MySheet.UsedRange.EntireRow.Height

Is ready only. Unfortunately it won't work.

Try this:

NamedRange.RowHeight = X;

Please check MSDN for more info. : http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.namedrange.rowheight%28v=vs.80%29.aspx


This works for me:

var SomeCell = (Excel.Range)_xlSheet.Cells[1, 1];             
SomeCell.Value2 = "What was D.D. Eisenhower's Gettysburg Address?";
SomeCell.RowHeight = 32;


Try this

sampleRange.Resize.RowHeight=x; //x's type must int


try this, you can loop true all rows with a for loop something like this

  int i = 0;

        for (var i = 0; i < column.Count(); i++)
        {
            worksheet.Row(i).Height = 100;
        }


 using (XLWorkbook xLWorkbook = new XLWorkbook())
       {
         var wordsheet = xLWorkbook.Worksheets.Add(dtEmpDetail, status);
         wordsheet.Row(2).Height = 50;
         wordsheet.Range("A1:d2").Merge();
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号