private void button1_Click(object sender, EventArgs e) { // ExStart:AddingColumnStyle // Accessing the worksheet of the Grid that is currently active Worksheet sheet = gridDesktop1.GetActiveWorksheet(); // Accessing the first column of the worksheet Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0]; // Adding sample value to sheet cell GridCell cell = sheet.Cells["a1"]; cell.SetCellValue("Aspose"); // Getting the Style object for the column Style style = column.GetStyle(); // Setting Style properties i.e. border, alignment color etc. style.SetBorderLine(BorderType.Right, BorderLineType.Thick); style.SetBorderColor(BorderType.Right, Color.Blue); style.HAlignment = HorizontalAlignmentType.Centred; // Setting the style of the column with the customized Style object column.SetStyle(style); // ExEnd:AddingColumnStyle gridDesktop1.Refresh(); }
private void button1_Click(object sender, EventArgs e) { // ExStart:SetColumnWidth // Accessing the worksheet of the Grid that is currently active Worksheet sheet = gridDesktop1.GetActiveWorksheet(); // Adding sample value to sheet cell GridCell cell = sheet.Cells["a1"]; cell.SetCellValue("Welcome to Aspose!"); // Accessing the first column of the worksheet Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0]; // Setting the width of the column column.Width = 150; // ExEnd:SetColumnWidth }