Exemple #1
0
 private void CopyDataToWorksheet(Worksheet sheet, ListView[] listViewList)
 {
   int num = 2;
   int count = listViewList[0].Columns.Count;
   for (int index = 0; index < count; ++index)
   {
     ColumnHeader columnHeader = listViewList[0].Columns[index];
     Range range = sheet.GetRange(1, index + 1);
     range.Bold = true;
     range.Value = (object) columnHeader.Text;
   }
   foreach (ListView listView in listViewList)
   {
     for (int index1 = 0; index1 < listView.Items.Count; ++index1)
     {
       ListViewItem listViewItem = listView.Items[index1];
       for (int index2 = 0; index2 < listViewItem.SubItems.Count && index2 < count; ++index2)
       {
         Range range = sheet.GetRange(index1 + num, index2 + 1);
         if (listViewItem.SubItems[index2].Font.Italic)
           range.Italic = true;
         if (listViewItem.SubItems[index2].Font.Bold)
           range.Bold = true;
         if (listViewItem.SubItems[index2].Font.Underline)
           range.Underline = true;
         range.Value = (object) listViewItem.SubItems[index2].Text;
       }
     }
     num += listView.Items.Count;
   }
 }
Exemple #2
0
 private void CopyDataToWorksheet(Worksheet sheet, PortfolioPerformance portfolioPerformance)
 {
   int num = 2;
   Range range1 = sheet.GetRange(1, 1);
   range1.Bold = true;
   range1.Value = (object) "DateTime";
   Range range2 = sheet.GetRange(1, 2);
   range2.Bold = true;
   range2.Value = (object) "Equity";
   Range range3 = sheet.GetRange(1, 3);
   range3.Bold = true;
   range3.Value = (object) "Drowdawn";
   for (int index = 0; index < portfolioPerformance.EquitySeries.Count; ++index)
   {
     sheet.GetRange(num + index, 1).Value = (object) portfolioPerformance.EquitySeries.GetDateTime(index).ToString();
     sheet.GetRange(num + index, 2).Value = (object) portfolioPerformance.EquitySeries[index];
     sheet.GetRange(num + index, 3).Value = (object) portfolioPerformance.DrawdownSeries[index];
   }
 }
 private void CopyDataToWorksheet(Worksheet sheet, DataGridView[] dgvList)
 {
     int num = 2;
     int count = dgvList[0].Columns.Count;
     for (int index = 0; index < count; ++index)
     {
         DataGridViewColumn dataGridViewColumn = dgvList[0].Columns[index];
         Range range = sheet.GetRange(1, index + 1);
         range.Bold = true;
         range.Value = (object)dataGridViewColumn.HeaderText;
     }
     foreach (DataGridView dataGridView in dgvList)
     {
         for (int index1 = 0; index1 < dataGridView.Rows.Count; ++index1)
         {
             DataGridViewRow dataGridViewRow = dataGridView.Rows[index1];
             for (int index2 = 0; index2 < dataGridViewRow.Cells.Count && index2 < count; ++index2)
             {
                 Range range = sheet.GetRange(index1 + num, index2 + 1);
                 Font font = dataGridViewRow.Cells[index2].Style.Font ?? dataGridViewRow.Cells[index2].InheritedStyle.Font;
                 if (font.Italic)
                     range.Italic = true;
                 if (font.Bold)
                     range.Bold = true;
                 if (font.Underline)
                     range.Underline = true;
                 range.Value = (object)dataGridViewRow.Cells[index2].Value.ToString();
             }
         }
         num += dataGridView.Rows.Count;
     }
 }