I'm exporting data to an Excel spreadsheet and I'm not able to use AutoFit, could anyone help me?
Code:
public void exportarExcel(InformacaoDB info, string nomeArquivo)
{
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Cells[1, 1] = "Cliente";
xlWorkSheet.Cells[1, 2] = "Nome do Servidor";
xlWorkSheet.Cells[1, 3] = "Uso de Processamento (%)";
xlWorkSheet.Cells[1, 4] = "Uso de Armazenamento (%)";
xlWorkSheet.Cells[2, 1] = info.Cliente;
xlWorkSheet.Cells[2, 2] = info.NomeServidor;
xlWorkSheet.Cells[2, 3] = info.UsoProcessamento;
xlWorkSheet.Cells[2, 4] = info.UsoArmazenamento;
}