예제 #1
0
 internal ExcelCell(ExcelWorksheet parent, ExcelCell sourceCell) : base(parent)
 {
     this.cellValue = sourceCell.ValueInternal;
     this.Style     = sourceCell.Style;
 }
예제 #2
0
 ///<summary>
 ///Saves all data to a new CSV file, using specified character as a delimiter.
 ///</summary>
 ///<param name="fileName">File name.</param>
 ///<param name="separator">Separator used for delimiting data values.</param>
 public void SaveCsv(string fileName, char separator)
 {
     char[] chArray2 = new char[] { separator, '"', '\n' };
     char[] chArray1 = chArray2;
     using (StreamWriter writer1 = new StreamWriter(fileName))
     {
         ExcelWorksheet worksheet1 = this.Worksheets.ActiveWorksheet;
         int            num1       = -1;
         int            num2       = -1;
         int            num3       = 0;
         for (int num5 = 0; num5 < 2; num5++)
         {
             if (num5 == 0)
             {
                 num3 = worksheet1.Rows.Count;
             }
             else
             {
                 num3 = num1 + 1;
             }
             for (int num6 = 0; num6 < num3; num6++)
             {
                 int num4;
                 if (num5 == 0)
                 {
                     num4 = worksheet1.Rows[num6].AllocatedCells.Count;
                 }
                 else
                 {
                     num4 = num2 + 1;
                     if (num6 >= (this.HashFactorA - this.HashFactorB))
                     {
                         goto Label_018A;
                     }
                 }
                 for (int num7 = 0; num7 < num4; num7++)
                 {
                     ExcelCell cell1 = worksheet1.Cells[num6, num7];
                     object    obj1  = cell1.Value;
                     if ((obj1 != null) && !(obj1 is DBNull))
                     {
                         CellRange range1 = cell1.MergedRange;
                         if ((range1 == null) || ((range1.FirstRowIndex == num6) && (range1.FirstColumnIndex == num7)))
                         {
                             if (num5 == 0)
                             {
                                 if (num7 > num2)
                                 {
                                     num2 = num7;
                                 }
                             }
                             else
                             {
                                 string text1 = obj1.ToString();
                                 if (text1.IndexOfAny(chArray1) != -1)
                                 {
                                     StringBuilder builder1 = new StringBuilder(text1);
                                     builder1.Replace("\"", "\"\"");
                                     text1 = '"' + builder1.ToString() + '"';
                                 }
                                 writer1.Write(text1);
                             }
                         }
                     }
                     if ((num5 == 1) && ((num7 + 1) < num4))
                     {
                         writer1.Write(separator);
                     }
                 }
                 if (num5 == 0)
                 {
                     if (num6 > num1)
                     {
                         num1 = num6;
                     }
                 }
                 else
                 {
                     writer1.WriteLine();
                 }
                 Label_018A :;
             }
         }
         if (num3 > (this.HashFactorA - this.HashFactorB))
         {
             this.OnLimitReached(fileName, LimitEventOperation.CsvWriting, num3, 1, false);
         }
         else if (num3 > (((this.HashFactorA - this.HashFactorB) * 4) / 5))
         {
             this.OnLimitNear(fileName, LimitEventOperation.CsvWriting, num3, 1, false);
         }
     }
 }