Freeze Rows In Excel

by ssi 13. January 2016 08:13
wb.PrintHCenter = true;
      int nTopFreezeRow = 0;
      int nIgnore = 0;
      int nBottomFreezeRow = 4;
     string stest = "$1:$3,$C:$C";
      stest = string.Format("${0}:${1},${2}:${2}", 1,   nBottomFreezeRow, "C"); //must  be 1
      wb.PrintTitles = stest; //Not  sure  about the $C:$C part
      wb.freezePanes(nTopFreezeRow, nIgnore, nBottomFreezeRow, nIgnore, false);
 
      if (BigPaper)
          wb.setPrintPaperSize((int)(8.5 * 1440), (int)(14 * 1440));
      RangeStyle rs = wb.getRangeStyle();

Tags: , , ,

CSharp | SmartXLS

Chart Class Using Smart XLS

by ssi 25. December 2015 16:58
using SmartXLS;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
 
namespace ChartClass
{
    public class clsPROD_DbSizeChart
    {
        private string sStartRange;
        private string sEndRange;
        private string sRngTotal;
 
        public string _acct = "_($* #,##0_);_($* (#,##0);_($* \"-\"??_);_(@_)",
               _noterate = "#,##0.000_);(#,##0.000);_($* \"-\"??_)",
               _currency = "$#,##0.00_);($#,##0.00)",
               _txt = "@",
               _date = "m/d/yyyy",
               _general = "General",
               _generalNumber = "#,##0;(#,##0);_(* \"-\"??_)",
               _intNumber = "#,##0;(#,##0);_(* \"-\"??_)",
               _genNum3 = "#,##0.000;(#,##0.000);_(* \"-\"??_)",
               _percent = "#,##0.00%;(#,##0.00%);_(* \"-\"??_)";
 
        public List<ChartData> CHARTDATA { getset; }
        public string ReportingClassName { getset; }
        public bool ExcelTableFormat { getset; }
        public string CallingAppVersion { getset; }
        public int LoanCount { getset; }
        public string CallingApp { getset; }
        public string ResultType { getset; }
 
        public string RunNote { getset; }
 
        public string ConnectionString { getset; }
 
        public string ReportTitle { getset; }
 
        public string User { getset; }
 
        public string Version { getset; }
 
        public string PageNumber { getset; }
 
        public string ExportPathName { getset; }
 
        public DateTime StartDate { getset; }
 
        public DateTime EndDate { getset; }
 
        public int SheetNumber { getset; }
        public int LastXDays { getset; }
 
        public string SheetName { getset; }
 
        #region Constructor
 
        public clsPROD_DbSizeChart(string sConnect)
        {
            ConnectionString = sConnect;
            // LOG = swLog;
        }
 
        #endregion Constructor
 
        public void ProcessMe(WorkBook wb)
        {
            //format
            //http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
            // WorkBook wb;
            DateTime dStart = StartDate;
            DateTime dEnd = EndDate;
            // string StartRange, eRange, rngTotal;
            decimal nStart;
            bool b = decimal.TryParse(dStart.ToString("yyyyMMdd"), out nStart);
            decimal nEnd;
            b = decimal.TryParse(dEnd.ToString("yyyyMMdd"), out nEnd);
 
            //AMCSupportDataClassesDataContext dcSupport = new AMCSupportDataClassesDataContext(clsCommonStatics.GetSupportConnectionString());
 
        
 
            #region ExcelExport
 
            wb.NumSheets = SheetNumber + 1;
            wb.setSheetName(SheetNumber, SheetName);
            wb.Sheet = SheetNumber;
            double nMarBot = wb.PrintBottomMargin;
            double nMarTop = wb.PrintTopMargin;
            double nMarRt = wb.PrintRightMargin;
            double nMarLt = wb.PrintLeftMargin;
 
            wb.PrintHeader = "";
            wb.PrintFooterMargin = .25d;
            wb.PrintBottomMargin = .5d;
            wb.PrintTopMargin = .25d;
            wb.PrintRightMargin = .25d;
            wb.PrintLeftMargin = .25d;
            wb.PrintGridLines = true;
            wb.PrintScaleFitVPages = 2;
            wb.PrintScaleFitHPages = 1;
            wb.PrintScaleFitToPage = true;
            wb.PrintHCenter = true;
            wb.PrintTitles = "$1:$4,$C:$C"//Not  sure  about the $C:$C part
            wb.setPrintPaperSize((int)(8.5 * 1440), (int)(14 * 1440));
            int nTopFreezeRow = 0;
            int nIgnore = 0;
            int nBottomFreezeRow = 4;
            wb.freezePanes(nTopFreezeRow, nIgnore, nBottomFreezeRow, nIgnore, false);
            wb.PrintLandscape = true;
            RangeStyle rs = wb.getRangeStyle();
 
            int nCol = 0;
            int nRow = 0;
 
          VS201300.clsSXFormatter oFrm = new VS201300.clsSXFormatter(wb);
 
            int nLastCol = 4;
            oFrm.HorizontalAlignment = RangeStyle.HorizontalAlignmentCenterAcrossCells;
            oFrm.Pattern = RangeStyle.PatternSolid;// 1;
            oFrm.PatternFG = Color.MidnightBlue.ToArgb();
            oFrm.FontColor = Color.White;
 
            string[] aHeader =  {
                                  "Date DownLoaded"
                                 ,"File Size"
                                                          };
 
            oFrm.WriteText(ReportTitle, nRow, 0, nRow, aHeader.Length - 1, true, 12, false);
            nRow++;
            oFrm.WriteText(string.Format("Date Range: {0:d} to {1:d}", StartDate, EndDate), nRow, 0, nRow, aHeader.Length - 1, true, 10, false);
            nRow++;
            oFrm.WriteText(string.Format("Run Date: {0:d}"DateTime.Today), nRow, 0, nRow, aHeader.Length - 1, true, 10, false);
            nRow++;
 
            oFrm.WriteText("", nRow, 0, nRow, aHeader.Length - 1, true, 10, false);
 
            nCol = 0;
 
            nCol = 1;
            nCol = 0;
            oFrm.Wrap = true;
            foreach (string s in aHeader)
            {
                oFrm.WriteText(s.Replace("_"" "), nRow, nCol, nRow, nCol, true, 10, true);
                nCol++;
            }
            oFrm.Pattern = RangeStyle.PatternNull;
            oFrm.FontColor = Color.Black;
            oFrm.HorizontalAlignment = RangeStyle.HorizontalAlignmentLeft;
            oFrm.Wrap = false;
            nRow++;
 
            nCol = 0;
            int nLoanCount = 0;
            int nStartRow = nRow;
            int nEndRow = nRow;
            var Sorted = CHARTDATA.OrderBy(r => r.Label);
            int nChartStartRow = nRow;
            foreach (var ln in Sorted)
            {
                oFrm.HorizontalAlignment = RangeStyle.HorizontalAlignmentLeft;
 
                oFrm.WriteText(string.Format("{0}", ln.Label), nRow, nCol, nRow, nCol, false, 10, false);
                wb.setColWidth(nCol, 35 * 256);
                nCol++;
             
 
                oFrm.WriteNumber((double)ln.Value, nRow, nCol, nRow, nCol, false, 10, _genNum3);
                wb.setColWidth(nCol, 20 * 256);
                nCol++;
 
                nEndRow = nRow;
                nRow++;
 
                nCol = 0;
                nLoanCount++;
            }
 
            int nChartEndRow = nEndRow + 1;
 
            int nBottomVertRow = nRow - 1;
 
            #endregion ExcelExport
 
            //  oFrm.WriteText("Loans displayed in red font have not been exported via the GL TRANS report.  The GL TRANS needs to be generated for the date range listed for the loans in red font.", nRow, nCol, nRow, nCol, true, 10, false);
            oFrm.FontColor = Color.Black;
 
            #region UserHouseKeeping
 
            nRow++;
            nRow++;
            nRow++;
 
            VS201300.clsInfo oABt = new VS201300.clsInfo();
            oFrm.WriteText(string.Format("AMC Support Version {0} Report Library Version {1}", Version, oABt.VS2103Version), nRow, 0, nRow, nLastCol, true, 8, false);
       
            #endregion UserHouseKeeping
 
            LoanCount = nLoanCount;
 
          
            wb.Sheet = 0;
 
            #region Chart
 
            //create chart with it's location
            //Columns & Rows
            int left = 3;
            int top = 6;
            int right = 20;
            int bottom = 40;
 
            //create chart with it's location
            ChartShape chart = wb.addChart(left, top, right, bottom);
            chart.ChartType = ChartShape.Line;
 
            string sRange = string.Format("{0}!$A${1}:$B${2}", SheetName, nStartRow, nEndRow);
 
            chart.setLinkRange(sRange, false);
            //set axis title
            chart.setAxisTitle(ChartShape.XAxis, 0, "Date");
            chart.setAxisTitle(ChartShape.YAxis, 0, "Gbytes");
            //set series name
            chart.setSeriesName(0, "File Size");
            //chart.setSeriesName(1, "My Series number 2");
 
            chart.Title = "Download File Size Chart [PROD]";
 
            //set plot area's color to darkgray
            ChartFormat chartFormat = chart.PlotFormat;
            chartFormat.setSolid();
            chartFormat.ForeColor = Color.DarkGray.ToArgb();
            chart.PlotFormat = chartFormat;
 
            //set series 0's color to blue
            ChartFormat seriesformat = chart.getSeriesFormat(0);
            chartFormat.setSolid();
            seriesformat.ForeColor = Color.Red.ToArgb();
            chart.setSeriesFormat(0, seriesformat);
 
            //set series 1's color to red
            //seriesformat = chart.getSeriesFormat(1);
            //seriesformat.setSolid();
            //seriesformat.ForeColor = Color.Red.ToArgb();
            //chart.setSeriesFormat(1, seriesformat);
 
            //set chart title's font property
            ChartFormat titleformat = chart.TitleFormat;
            titleformat.FontSize = 14 * 20;
            titleformat.FontUnderline = true;
            chart.TitleFormat = titleformat;
 
            #endregion Chart
        }
 
      
    }
}

Tags: , , ,

CSharp | linq | SmartXLS

Calendar

<<  May 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

""If everyone is thinking alike, someone isn't thinking.""
- General George Patton Jr