Cells.SetColumnWidthPixel

Cells.SetColumnWidthPixel method

Sets column width in unit of pixels in normal view.

public void SetColumnWidthPixel(int column, int pixels)
ParameterTypeDescription
columnInt32Column index.
pixelsInt32Number of pixels.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsMethodSetColumnWidthPixelWithInt32Int32Demo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            Cells cells = worksheet.Cells;

            // Set column widths in pixels for columns 1 through 5
            for (int i = 0; i < 5; i++)
            {
                cells.SetColumnWidthPixel(i, 120); // 120 pixels width
            }

            // Save the workbook
            workbook.Save("SetColumnWidthPixelDemo.xlsx");
        }
    }
}

See Also