Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to set width/columns and height/rows in Excel using wpf?

$
0
0

Hi all,

I found a code of how to write some data in excel ... but it is possible with this code, maybe with some changes, set width/columns and height/rows?thanks so much... and here is my code ...

public void ExcelWrite()
        {
            var excelApp = new Excel.Application();
            excelApp.Visible = true;
            excelApp.Workbooks.Add();
            Excel._Worksheet workSheet = (Excel.Worksheet)excelApp.ActiveSheet;
            workSheet.Cells[1, "A"] = "ID Number";
            workSheet.Cells[1, "B"] = "Current Balance";
            var row = 1;
            for (int i=0; i<2; i++)
            {
                row++;
                workSheet.Cells[row, "A"] = "A + " + i;
                workSheet.Cells[row, "B"] = "B + " + i;
            }
            ((Excel.Range)workSheet.Columns[1]).AutoFit();
            ((Excel.Range)workSheet.Columns[2]).AutoFit();
        }


Viewing all articles
Browse latest Browse all 18858

Trending Articles