Ejemplo n.º 1
0
        private void ClearReport(bool autoFit, Workbook book, List <ReportSheetTemplate> tplList)
        {
            for (int i = 0; i < book.Worksheets.Count &&
                 i < tplList.Count; i++)
            {
                Spire.Xls.Worksheet worksheet = book.Worksheets [i];

                ReportSheetTemplate tpl = tplList [i];
                JoinTable(worksheet, tpl);
                // Clear Data
                Clear(worksheet, tpl.startRowIndex);

                if (autoFit || tpl.autoFit)
                {
                    CellRange range = RangeHelper.GetRange(worksheet, 1, 15, 50, 100);
                    range.AutoFitColumns();


                    /*for (int j = 1; j < 100; j++)
                     * {
                     *      try
                     *      {
                     *              worksheet.AutoFitColumn (j);
                     *      }
                     *      catch (Exception e)
                     *      {
                     *              Console.Write (e) ;
                     *      }
                     * }
                     */
                }

                // .GetType ().GetMethod ("AutoFit").Invoke (range, new object[0]) ;
                // copy image

                /*for (int j = 0; tpl.pics != null &&
                 *              j < tpl.pics.Count &&
                 *              j < worksheet.Pictures.Count; j++)
                 * {
                 *      Rectangle pic = tpl.pics [i] ;
                 *
                 *
                 *      int tmp = worksheet.Pictures [i].TopRow ;
                 *      tmp = worksheet.Pictures[i].TopRowOffset;
                 *      tmp = worksheet.Pictures[i].LeftColumn;
                 *      tmp = worksheet.Pictures[i].LeftColumnOffset;
                 *      tmp = worksheet.Pictures [i].BottomRow ;
                 *      tmp = worksheet.Pictures [i].BottomRowOffset ;
                 *      tmp = worksheet.Pictures [i].RightColumn ;
                 *      tmp = worksheet.Pictures [i].RightColumnOffset ;
                 *
                 *      worksheet.Pictures [i].Left = pic.X ;
                 *      worksheet.Pictures [i].Top = pic.Y ;
                 *      worksheet.Pictures [i].Height = pic.Height ;
                 *      worksheet.Pictures [i].Width = pic.Width ;
                 *
                 * }*/
            }

            // remove warnning sheet.

/*
 *                      IEnumerator e = xlapp.ActiveWorkbook.Worksheets.GetEnumerator();
 *                      while (e.MoveNext())
 *                      {
 *                              Worksheet sheet = (Worksheet)e.Current;
 *
 *                              if (sheet.Name.IndexOf("Warning") >= 0)
 *                                      sheet.Delete();
 *                      }
 *                      ((_Worksheet)xlapp.ActiveWorkbook.Worksheets[1]).Activate ();
 *                      ((Worksheet)xlapp.ActiveWorkbook.Worksheets [1]).get_Range("A1", "A1").Activate();
 *                      // only save activeWorkBook
 *                      xlapp.ActiveWorkbook.Save ();
 *                      // only close activeWorkbook ;
 *                      xlapp.ActiveWorkbook.Close (true, Missing.Value, Missing.Value);
 *                      // xlapp.Workbooks.Close ();
 */
        }