public void SetData(System.Data.DataTable table, int bold, int italic,int rows_offset)
 {
     try
     {
         if (WorksheetInitialized)
         {
             CurrentRow += rows_offset;
             int TableRows = table.Rows.Count;
             int TableCols = table.Columns.Count;
             char ACol = 'A';
             Range TableRange = ItsWorksheet.get_Range("A" + CurrentRow,
                 ((char)((int)ACol + TableCols - 1)).ToString() + (CurrentRow + TableRows).ToString());
             TableRange.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
             for (int i = 0; i < TableCols; i++)
             {
                 Range names_range = ItsWorksheet.get_Range(((char)((int)ACol + i)).ToString() + CurrentRow,
                     ((char)((int)ACol + i)).ToString() + CurrentRow);
                 names_range.Value2 = table.Columns[i].ColumnName;
             }
             for (int i = 1; i < TableRows + 1; i++)
             {
                 for (int j = 0; j < TableCols; j++)
                 {
                     Range cell_range = ItsWorksheet.get_Range(((char)((int)ACol + j)).ToString() + (CurrentRow + i),
                     ((char)((int)ACol + j)).ToString() + (CurrentRow + i));
                     cell_range.Value2 = table.Rows[i - 1].ItemArray[j];
                     cell_range.Font.Bold = bold;
                     cell_range.Font.Italic = italic;
                 }
             }
             CurrentRow += TableRows;
         }
         else
             MessageBox.Show(
                 "Cannot output any text!\n" +
                 "Worksheed didnot created!",
                 "Error!!!", MessageBoxButtons.OK,
                 MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error!!!", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     }
 }
 public void SetText(string text,int bold,int italic,int cells_offset)
 {
     try
     {
         if (WorksheetInitialized)
         {
             ArrayList lines_list = new ArrayList();
             string curr_line = "";
             for (int i = 0; i < text.Length; i++)
             {
                 if (text[i] == '\n' || (i == text.Length - 1))
                 {
                     lines_list.Add(curr_line);
                     curr_line = "";
                 }
                 curr_line += text[i];
             }
             CurrentRow += cells_offset;
             foreach (object line in lines_list)
             {
                 Range text_range =
                     ItsWorksheet.get_Range("A" + CurrentRow, "A" + CurrentRow);
                 text_range.Font.Bold = bold;
                 text_range.Font.Italic = italic;
                 text_range.Value2 = line;
                 text_range.WrapText = false;
                 CurrentRow++;
             }
         }
         else
             MessageBox.Show(
                 MessageBox.Show(
                 "Cannot output any text!\n" +
                 "Worksheed didnot created!",
                 "Error!!!", MessageBoxButtons.OK,
                 MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error!!!", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     }
 }
 public void SaveCurrentWorksheet(string filename)
 {
     try
     {
         ItsWorksheet.SaveAs(filename,
             MissingValue,
             MissingValue,
             MissingValue,
             MissingValue,
             MissingValue,
             MissingValue,
             MissingValue,
             MissingValue,
             MissingValue);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error!!!", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     }
 }