Example #1
0
        private static int FullGetRowHeight(TFlxFont Fx)
        {
            if (Fx.Size20 < 8 * 20)         //Fonts less than 8 points are all the same
            {
                int[] heights = { 105, 105, 105, 120, 135, 165, 165, 180, 180 };
                return(heights[(int)Math.Round(Fx.Size20 / 20f)]);
            }

            if (
                (
                    String.Equals(Fx.Name, "ARIAL", StringComparison.InvariantCultureIgnoreCase)
                    ||
                    String.Equals(Fx.Name, "TIMES NEW ROMAN", StringComparison.InvariantCultureIgnoreCase)
                ) &&
                Fx.Size20 == 200 && Fx.Style == TFlxFontStyles.None)
            {
                return(0xFF);                //Most usual case.
            }
            if (MissingFrameworkFont)
            {
                return(0xFF);
            }
            try
            {
                int Result = DoFullGetRowHeight(Fx);
                return(Result);
            }
            catch (MissingMethodException)
            {
                MissingFrameworkFont = true;
                return(7);
            }
        }
Example #2
0
        internal Font GetFont(TFlxFont Fx, real Adj)
        {
            // Not really need to keep a cache in WPF.
            Font NewFont = ExcelFont.CreateFont(Fx, Adj);

            return(NewFont);
        }
Example #3
0
        private static real FullGetFont0Width(TFlxFont Fx)
        {
            if (String.Equals(Fx.Name, "ARIAL", StringComparison.InvariantCultureIgnoreCase) && Fx.Size20 == 200 && Fx.Style == TFlxFontStyles.None)
            {
                return(7);                //Most usual case.
            }
            if (MissingFrameworkFont)
            {
                return(7);
            }

            if (String.Equals(Fx.Name, CachedFontName, StringComparison.InvariantCultureIgnoreCase) && Fx.Size20 == CachedFontSize && Fx.Style == CachedFontStyle)
            {
                return(CachedFontWidth); //Most usual case.
            }
            try
            {
                real Result = DoFullGetFont0Width(Fx);
                CachedFontWidth = Result;
                CachedFontName  = Fx.Name;
                CachedFontSize  = Fx.Size20;
                CachedFontStyle = Fx.Style;
                return(Result);
            }
            catch (MissingMethodException)
            {
                MissingFrameworkFont = true;
                return(7);
            }
        }
Example #4
0
        private static real DoFullGetFont0Width(TFlxFont Fx)
        {
            TextBlock tb = new TextBlock();

            ExcelFont.SetFont(tb, Fx);
            tb.Text = "0";
            return((real)tb.ActualWidth); //Result is in silverlight pixels. Note that no transformation applies to TextBlock
        }
Example #5
0
 /// <summary>
 /// Returns the Height of an XF format Excel.
 /// </summary>
 /// <param name="Fx"></param>
 /// <returns></returns>
 internal static int GetRowHeightInPixels(TFlxFont Fx)
 {
     try
     {
         return(FullGetRowHeight(Fx));
     }
     catch (TypeLoadException)
     {
         return(0xFF);
     }
 }
Example #6
0
 internal static real GetFont0Width(TFlxFont Fx)
 {
     try
     {
         return(FullGetFont0Width(Fx));
     }
     catch (TypeLoadException)
     {
         return(7);
     }
 }
Example #7
0
        private static int DoFullGetRowHeight(TFlxFont Fx)
        {
            using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx)))
            {
#if (MONOTOUCH)
                real h = MyFont.LineHeight;
#else
                real h = MyFont.GetHeight(75);
#endif
                return((int)(h * 20.87 + 5));
            }
        }
Example #8
0
        private void DumpFile(ExcelFile Xls, ref int Row)
        {
            TFlxFont fnt = Xls.GetDefaultFont;

            fnt.Color = Color.Blue;
            int HighlightFont = Xls.AddFont(fnt);

            fnt.Color = Color.Green;
            int CommentFont = Xls.AddFont(fnt);

            int         Level      = 0;
            Stack <int> LevelStart = new Stack <int>();

            LevelStart.Push(Row);

            using (StreamReader sr = new StreamReader(Path.Combine(PathToExe, "Form1.cs")))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    //Find the level of "keep together" for the row. We will use #region and "{" delimiters
                    //to increase the level. If possible, we would want those blocks together in one page.
                    string s = line.Trim();
                    if (s.StartsWith("#region"))
                    {
                        Level++; LevelStart.Push(Row);
                    }
                    if (s == "{")
                    {
                        Level++;
                        LevelStart.Push(Row - 1);//On {} blocks, we want to keep lines together starting with the previous statement.
                    }

                    if (s == "#endregion" || s == "}")
                    {
                        Level--;
                        Xls.KeepRowsTogether(LevelStart.Pop(), Row, Level + 1, false);
                    }

                    Xls.KeepRowsTogether(Row, Row, Level, true);


                    Xls.SetCellValue(Row, 1, SyntaxColor(Xls, 0, CommentFont, HighlightFont, line.Replace("\t", "    ")));
                    Row++;
                }
            }
        }
Example #9
0
        private static real FullGetFont0Width(TFlxFont Fx)
        {
            if (String.Equals(Fx.Name, "ARIAL", StringComparison.InvariantCultureIgnoreCase) && Fx.Size20 == 200 && Fx.Style == TFlxFontStyles.None)
            {
                return(7); //Most usual case.
            }
            if (String.Equals(Fx.Name, CachedFontName, StringComparison.InvariantCultureIgnoreCase) && Fx.Size20 == CachedFontSize && Fx.Style == CachedFontStyle)
            {
                return(CachedFontWidth); //Most usual case.
            }
            real Result = DoFullGetFont0Width(Fx);

            CachedFontWidth = Result;
            CachedFontName  = Fx.Name;
            CachedFontSize  = Fx.Size20;
            CachedFontStyle = Fx.Style;
            return(Result);
        }
Example #10
0
        /// <summary>
        /// Tries to create a new font given the Excel data.
        /// </summary>
        /// <param name="Fx">FlexCel font with the font information.</param>
        /// <param name="Adj">An adjustment parameter to multiply the FontSize.</param>
        public static Font CreateFont(TFlxFont Fx, real Adj)
        {
            Font Result = new Font();

            Result.Family    = new FontFamily(Fx.Name);
            Result.SizeInPix = Fx.Size20 / 20.0 * FlxConsts.PixToPoints * Adj; //fontsize is in pixels, not points
            if ((Fx.Style & TFlxFontStyles.Italic) != 0)
            {
                Result.Style = FontStyles.Italic;
            }
            else
            {
                Result.Style = FontStyles.Normal;
            }
            if ((Fx.Style & TFlxFontStyles.Bold) != 0)
            {
                Result.Weight = FontWeights.Bold;
            }
            else
            {
                Result.Weight = FontWeights.Normal;
            }

            Result.Decorations = new TextDecorationCollection();
            if ((Fx.Style & TFlxFontStyles.StrikeOut) != 0)
            {
                Result.Decorations.Add(TextDecorations.Strikethrough);
            }
            if (Fx.Underline != TFlxUnderline.None)
            {
                Result.Decorations.Add(TextDecorations.Underline);
            }
            if (Fx.Underline == TFlxUnderline.Double || Fx.Underline == TFlxUnderline.DoubleAccounting)
            {
                Result.Decorations.Add(TextDecorations.Baseline);
            }

            Result.Freeze();
            return(Result);
        }
Example #11
0
        private static real DoFullGetFont0Width(TFlxFont Fx)
        {
#if (MONOTOUCH)
            using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx)))
            {
                using (MonoTouch.Foundation.NSString o = new MonoTouch.Foundation.NSString("0"))
                {
                    return(o.StringSize(MyFont).Width);
                }
            }
#else
            using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx)))
            {
                using (Bitmap bm = new Bitmap(1, 1))
                {
                    using (Graphics gr = Graphics.FromImage(bm))
                        using (StringFormat sfTemplate = StringFormat.GenericTypographic)                 //GenericTypographic returns a NEW instance. It has to be disposed.
                        {
                            using (StringFormat sf = (StringFormat)sfTemplate.Clone())                    //Even when sfTemplate is a new instance, changing directly on it will change the standard generic typographic :(
                            {
                                //sf.SetMeasurableCharacterRanges was causing a deadlock here.
                                //DONT DO!!

                                /*CharacterRange[] r = {new CharacterRange(0,1)};
                                 * sf.SetMeasurableCharacterRanges(r);*/

                                sf.Alignment     = StringAlignment.Near; //this should be set, but just in case someone changed it.
                                sf.LineAlignment = StringAlignment.Far;  //this should be set, but just in case someone changed it.
                                sf.FormatFlags   = 0;
                                gr.PageUnit      = GraphicsUnit.Pixel;
                                SizeF sz = gr.MeasureString("0", MyFont, 1000, sf);
                                return((real)Math.Round(sz.Width));
                            }
                        }
                }
            }
#endif
        }
Example #12
0
        /// <summary>
        /// Assigns an Excel font to a TextBlock
        /// </summary>
        /// <param name="tb">TextBlock to which assign the font.</param>
        /// <param name="Fx">Font to assign.</param>
        public static void SetFont(TextBlock tb, TFlxFont Fx)
        {
            tb.FontFamily = new FontFamily(Fx.Name);
            tb.FontSize   = Fx.Size20 / 20.0 * FlxConsts.PixToPoints; //fontsize is in pixels, not points
            if ((Fx.Style & TFlxFontStyles.Italic) != 0)
            {
                tb.FontStyle = FontStyles.Italic;
            }
            else
            {
                tb.FontStyle = FontStyles.Normal;
            }
            if ((Fx.Style & TFlxFontStyles.Bold) != 0)
            {
                tb.FontWeight = FontWeights.Bold;
            }
            else
            {
                tb.FontWeight = FontWeights.Normal;
            }

#if (!SILVERLIGHT)
            if ((Fx.Style & TFlxFontStyles.StrikeOut) != 0)
            {
                tb.TextDecorations.Add(TextDecorations.Strikethrough);
            }
#endif
            if (Fx.Underline != TFlxUnderline.None)
            {
                tb.TextDecorations.Add(TextDecorations.Underline);
            }
            if (Fx.Underline == TFlxUnderline.Double || Fx.Underline == TFlxUnderline.DoubleAccounting)
            {
                tb.TextDecorations.Add(TextDecorations.Baseline);
            }
        }
Example #13
0
        /// <summary>
        /// 给单元格添加标注
        /// </summary>
        /// <param name="row">单元格所在行</param>
        /// <param name="col">单元格所在列</param>
        /// <param name="comment">标注</param>
        public void AddCommentToCell(int row, int col, string commentTitle, string commentDetail)
        {
            string comment = string.Format("{0}\n{1}\n", commentTitle, commentDetail);

            // 设置单元格背景色
            TFlxFormat fmt = xls.GetCellVisibleFormatDef(row, col);

            fmt.FillPattern.Pattern = TFlxPatternStyle.Solid;
            fmt.FillPattern.FgColor = Color.FromArgb(0xFF9999);
            xls.SetCellFormat(row, col, xls.AddFormat(fmt));

            // 设置批注
            TRTFRun[] Runs = new TRTFRun[3];
            Runs[0].FirstChar = 0;
            TFlxFont fnt = xls.GetDefaultFont;

            fnt.Size20        = 180;
            fnt.Color         = TExcelColor.Automatic;
            fnt.Style         = TFlxFontStyles.Bold;
            fnt.Family        = 3;
            fnt.CharSet       = 134;
            fnt.Scheme        = TFontScheme.None;
            Runs[0].FontIndex = xls.AddFont(fnt);
            Runs[1].FirstChar = 7;
            fnt               = xls.GetDefaultFont;
            fnt.Size20        = 180;
            fnt.Color         = TExcelColor.Automatic;
            fnt.Family        = 3;
            fnt.CharSet       = 134;
            fnt.Scheme        = TFontScheme.None;
            Runs[1].FontIndex = xls.AddFont(fnt);
            Runs[2].FirstChar = 13;
            fnt               = xls.GetDefaultFont;
            Runs[2].FontIndex = xls.AddFont(fnt);
            xls.SetComment(row, col, new TRichString(comment, Runs, xls));
        }
Example #14
0
        internal static void WriteText(ExcelFile Workbook, IFlxGraphics Canvas, TFontCache FontCache, real Zoom100, Font AFont, Color AFontColor, real x, real y, real SubOfs, TRichString OutText, real Alpha, real MaxDescent, TAdaptativeFormats AdaptativeFormats)
        {
            if (OutText.Length == 0)
            {
                return;
            }

            if (Alpha != 0)
            {
                Canvas.SaveTransform();
            }
            try
            {
                if (Alpha != 0)
                {
                    Canvas.Rotate(x, y, Alpha);
                }

                using (Brush TextBrush = new SolidBrush(AFontColor))
                {
                    if (OutText.RTFRunCount == 0)
                    {
                        if (AdaptativeFormats == null || AdaptativeFormats.Separators == null || AdaptativeFormats.Separators.Length == 0) //formats are only applied to non rich text cells.
                        {
                            Canvas.DrawString(OutText.Value, AFont, TextBrush, x, y + SubOfs);
                        }
                        else
                        {
                            DrawAdaptativeString(Canvas, AdaptativeFormats, OutText.Value, AFont, TextBrush, x, y + SubOfs);
                        }
                    }
                    else
                    {
                        SizeF Result;

                        string s1 = OutText.Value.Substring(0, OutText.RTFRun(0).FirstChar);
                        if (s1.Length > 0)
                        {
                            Result = Canvas.MeasureString(s1, AFont, new TPointF(x, y));
                            Canvas.DrawString(s1, AFont, TextBrush, x, y + SubOfs - (MaxDescent - Canvas.FontDescent(AFont)));
                            x += Result.Width;
                        }

                        for (int i = 0; i < OutText.RTFRunCount - 1; i++)
                        {
                            TFlxFont       Fx     = OutText.GetFont(OutText.RTFRun(i).FontIndex);
                            TSubscriptData Sub    = new TSubscriptData(Fx.Style);
                            Font           MyFont = FontCache.GetFont(Fx, Zoom100 * Sub.Factor);
                            {
                                using (Brush MyBrush = new SolidBrush(GetColor(Workbook, Fx.Color)))
                                {
                                    int Start = OutText.RTFRun(i).FirstChar;
                                    if (Start >= OutText.Length)
                                    {
                                        Start = OutText.Length;
                                    }
                                    int Len = OutText.RTFRun(i + 1).FirstChar;
                                    if (Len >= OutText.Length)
                                    {
                                        Len = OutText.Length;
                                    }
                                    Len -= Start;

                                    string s2 = OutText.Value.Substring(Start, Len);
                                    Result = Canvas.MeasureString(s2, MyFont, new TPointF(x, y));
                                    Canvas.DrawString(s2, MyFont, MyBrush, x, y + Sub.Offset(Canvas, MyFont) - (MaxDescent - Canvas.FontDescent(MyFont)));
                                    x += Result.Width;
                                }
                            }
                        }
                        TFlxFont       Fy      = OutText.GetFont(OutText.RTFRun(OutText.RTFRunCount - 1).FontIndex);
                        TSubscriptData Suby    = new TSubscriptData(Fy.Style);
                        Font           MyFont2 = FontCache.GetFont(Fy, Zoom100 * Suby.Factor);
                        {
                            using (Brush MyBrush = new SolidBrush(GetColor(Workbook, Fy.Color)))
                            {
                                int Start = OutText.RTFRun(OutText.RTFRunCount - 1).FirstChar;
                                if (Start >= OutText.Length)
                                {
                                    Start = OutText.Length;
                                }

                                string s3 = OutText.Value.Substring(Start);
                                Result = Canvas.MeasureString(s3, MyFont2, new TPointF(x, y));
                                Canvas.DrawString(s3, MyFont2, MyBrush, x, y + Suby.Offset(Canvas, MyFont2) - (MaxDescent - Canvas.FontDescent(MyFont2)));
                            }
                        }
                    }
                }
            }
            finally
            {
                if (Alpha != 0)
                {
                    Canvas.ResetTransform();
                }
            }
        }
Example #15
0
        //
        // GET: /Home/ExportData_ToExcel/W0009
        public ActionResult E_ExportData_ToExcel(int way_bill_id)
        {
            if (Session["login_status"] != null)
            {

                //temp file name
                string copy_file_name = DateTime.Now.Ticks + ".xlsx";
                //template file name
                string Orginal_file_path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Report_Templates"), "Bolleto_Dogonale_Export.xlsx");
                //temp file path
                string copy_file_path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Images"), copy_file_name);

                XlsFile bolleto = new XlsFile(Orginal_file_path);

                bolleto.ActiveSheet = 1;

                var bolleto_code = (from i in db.Exports
                                    where i.e_way_bill_id == way_bill_id
                                    select i.e_bollete_dogonale_code).First();
                var j = 0;

                var bollete_dogonale = (from e in db.Exports
                                        join w in db.E_Way_Bill on e.e_way_bill_id equals w.e_way_bill_id
                                        join sd in db.Ship_Departure on e.ship_departure_id equals sd.ship_departure_id
                                        join cpc in db.E_Calculated_Payment_Config on w.e_way_bill_id equals cpc.way_bill_id
                                        where e.e_way_bill_id == way_bill_id
                                        select new Bolleto_DogonaleModel { way_bill_code = w.e_way_bill_code, import_code = e.export_code, ship_arrival_code = sd.ship_departure_code, bolleto_dogonale_code = e.e_bollete_dogonale_code, date = cpc.calculated_date });

                foreach (var item in bollete_dogonale)
                {

                    bolleto.SetCellValue(2, 3, item.bolleto_dogonale_code);
                    bolleto.SetCellValue(3, 3, item.way_bill_code);
                    bolleto.SetCellValue(4, 3, item.import_code);
                    bolleto.SetCellValue(5, 3, item.ship_arrival_code);
                    bolleto.SetCellValue(6, 3, item.date.ToString("yyyy-MM-dd"));
                    //bolleto.SetCellFormat(1, 1, 8, 7, 1);

                }
                var grand_total = db.E_Get_Grand_Total(way_bill_id, 100);
                string grand_total_value = "";
                foreach (var v in grand_total)
                {
                    grand_total_value = v;
                }
                db.E_Display_Tax_Details(way_bill_id, 100);
                var display1 = from d1 in db.E_TempDisplay1
                               where d1.way_bill_id == way_bill_id
                               select d1;
                var display2 = (from d2 in db.E_TempDisplay2
                                where d2.way_bill_id == way_bill_id
                                select d2).ToList();

                TFlxFormat tformatTitle = bolleto.GetCellVisibleFormatDef(9, 1);
                int titleFormat = bolleto.AddFormat(tformatTitle);

                TFlxFont tfont = new TFlxFont();
                tfont.Style = TFlxFontStyles.Bold;

                TFlxFormat tformatright = bolleto.GetCellVisibleFormatDef(10, 6);
                tformatright.Font = tfont;
                int Formatright = bolleto.AddFormat(tformatright);

                int iRowCnt = 9;

                foreach (var item in display1)
                {

                    // SHOW COLUMNS ON THE TOP.

                    bolleto.SetCellValue(iRowCnt, 1, "Goods", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 2, "Unit Price", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 3, "Calculated Tariff", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 4, "Total Quantity", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 5, "Unit Of Measure", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 6, "Base Taxation", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 7, "Total", titleFormat);

                    //bolleto.SetCellFormat(iRowCnt, 1, iRowCnt, 7, 1);
                    var x = "A" + iRowCnt;
                    var y = "G" + iRowCnt;

                    //xlWorkSheetToExport.Range[x, y].Font.Size = 11;
                    //xlWorkSheetToExport.Range[x, y].Font.Bold = true;

                    iRowCnt = iRowCnt + 1;
                    bolleto.SetCellValue(iRowCnt, 1, item.goods_name);
                    bolleto.SetCellValue(iRowCnt, 2, item.toal_Quantity);
                    bolleto.SetCellValue(iRowCnt, 3, item.Unit_Code);
                    bolleto.SetCellValue(iRowCnt, 4, item.Unit_Price);
                    bolleto.SetCellValue(iRowCnt, 5, item.calculated_Tariff);
                    bolleto.SetCellValue(iRowCnt, 6, item.Base_Taxation);
                    bolleto.SetCellValue(iRowCnt, 7, item.Total);
                    iRowCnt = iRowCnt + 2;
                    x = "A" + iRowCnt;
                    y = "G" + iRowCnt;
                    //xlWorkSheetToExport.Range[x, y].Font.Size = 11;
                    //xlWorkSheetToExport.Range[x, y].Font.Bold = true;

                    bolleto.SetCellValue(iRowCnt, 2, "Levy Name", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 3, "Levy Type", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 4, "Levy", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 5, "Actual Levy", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 6, "Total Levy", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 7, "");
                    //bolleto.SetCellFormat(iRowCnt, 1, iRowCnt, 7, 1);
                    iRowCnt = iRowCnt + 1;
                    for (var l = 0; l < display2.Count(); l++)
                    {
                        if (l == 0 && j != 0)
                        {
                            l = j;
                        }
                        if (item.Goods_Id != display2[l].Goods_Id)
                        {
                            break;
                        }
                        j++;
                        if (display2[l].Levy_Name == "Total")
                        {
                            bolleto.SetCellValue(iRowCnt, 2, display2[l].Levy_Name, titleFormat);
                            bolleto.SetCellValue(iRowCnt, 3, display2[l].Levy_Type, titleFormat);
                            bolleto.SetCellValue(iRowCnt, 4, display2[l].Levy, titleFormat);
                            //bolleto.SetCellValue(iRowCnt, 4).HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                            bolleto.SetCellValue(iRowCnt, 5, display2[l].Actua_Levy, Formatright);
                            bolleto.SetCellValue(iRowCnt, 6, display2[l].Total_Levi, Formatright);
                            bolleto.SetCellValue(iRowCnt, 7, display2[l].Sum_Levies, Formatright);
                            //bolleto.SetCellFormat(iRowCnt, 1, iRowCnt, 7, 1);
                            iRowCnt = iRowCnt + 1;
                        }
                        else
                        {
                            bolleto.SetCellValue(iRowCnt, 2, display2[l].Levy_Name);
                            bolleto.SetCellValue(iRowCnt, 3, display2[l].Levy_Type);
                            bolleto.SetCellValue(iRowCnt, 4, display2[l].Levy);
                            //bolleto.SetCellValue(iRowCnt, 4).HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                            bolleto.SetCellValue(iRowCnt, 5, display2[l].Actua_Levy);
                            bolleto.SetCellValue(iRowCnt, 6, display2[l].Total_Levi);
                            bolleto.SetCellValue(iRowCnt, 7, display2[l].Sum_Levies);
                            iRowCnt = iRowCnt + 1;
                        }
                    }
                    iRowCnt = iRowCnt + 1;
                }

                var get_payment_config = db.E_Calculated_Payment_Config.Where(cpc => cpc.way_bill_id == way_bill_id).ToList();
                foreach (var item in get_payment_config)
                {
                    TempData["sos_amount"] = item.calculated_sos_amount;
                    TempData["usd_amount"] = item.calculated_usd_amount;
                    TempData["sos"] = item.calculated_sos_part;
                    TempData["usd"] = item.calculated_usd_part;
                }

                iRowCnt = iRowCnt + 3;

                bolleto.SetCellValue(iRowCnt, 4, "USD Amount (" + TempData["usd"] + "%)", titleFormat);
                bolleto.SetCellValue(iRowCnt, 5, TempData["usd_amount"], titleFormat);

                iRowCnt++;

                bolleto.SetCellValue(iRowCnt, 4, "SOS Amount (" + TempData["sos"] + "%)", titleFormat);
                bolleto.SetCellValue(iRowCnt, 5, TempData["sos_amount"], titleFormat);

                iRowCnt++;

                bolleto.SetCellValue(iRowCnt,7,"Date : " + DateTime.Now.ToString("yyyy-MM-dd"));

                iRowCnt++;

                bolleto.SetCellValue(iRowCnt, 7, "User : "******"user_name"].ToString());

                var save_name = "Bolleto_Dogonale_Export_" + bolleto_code + ".xlsx";

                // SAVE THE FILE IN A FOLDER.
                //bolleto.Save(Path.Combine(Server.MapPath("~/App_Data"), copy_file_name));
                bolleto.Save(copy_file_path);

                this.DownLoadFile_Export(save_name, copy_file_path);

                return RedirectToAction("Index");

            }
            else
            {
                return RedirectToAction("../Home");
            }
        }
Example #16
0
        internal static SizeF CalcTextExtent(IFlxGraphics Canvas, TFontCache FontCache, real Zoom100,
                                             Font AFont, TRichString Text, out real MaxDescent)
        {
            MaxDescent = Canvas.FontDescent(AFont);
            if (Text.RTFRunCount == 0)
            {
                return(Canvas.MeasureStringEmptyHasHeight(Text.Value, AFont));
            }

            real  x = 0;
            real  y = 0;
            SizeF Result;

            Result = Canvas.MeasureString(Text.Value.Substring(0, Text.RTFRun(0).FirstChar), AFont, new TPointF(0, 0));
            x      = Result.Width; y = Result.Height;


            for (int i = 0; i < Text.RTFRunCount - 1; i++)
            {
                TFlxFont       Fx     = Text.GetFont(Text.RTFRun(i).FontIndex);
                TSubscriptData Sub    = new TSubscriptData(Fx.Style);
                Font           MyFont = FontCache.GetFont(Fx, Zoom100 * Sub.Factor);
                {
                    int Start = Text.RTFRun(i).FirstChar;
                    if (Start >= Text.Length)
                    {
                        Start = Text.Length;
                    }
                    int Len = Text.RTFRun(i + 1).FirstChar;
                    if (Len >= Text.Length)
                    {
                        Len = Text.Length;
                    }
                    Len -= Start;
                    if (Len < 0)
                    {
                        continue;       //wrong file, (i+1)FirstChar < (i).FirstChar
                    }
                    Result     = Canvas.MeasureString(Text.Value.Substring(Start, Len), MyFont, new TPointF(0, 0));
                    x         += Result.Width; y = Math.Max(y + Sub.Offset(Canvas, MyFont), Result.Height);
                    MaxDescent = Math.Max(MaxDescent, Canvas.FontDescent(MyFont) + Sub.Offset(Canvas, MyFont));
                }
            }


            TFlxFont       Fy      = Text.GetFont(Text.RTFRun(Text.RTFRunCount - 1).FontIndex);
            TSubscriptData Suby    = new TSubscriptData(Fy.Style);
            Font           MyFont2 = FontCache.GetFont(Fy, Zoom100 * Suby.Factor);

            {
                int Start = Text.RTFRun(Text.RTFRunCount - 1).FirstChar;
                if (Start >= Text.Length)
                {
                    Start = Text.Length;
                }
                Result     = Canvas.MeasureStringEmptyHasHeight(Text.Value.Substring(Start), MyFont2);
                x         += Result.Width; y = Math.Max(y + Suby.Offset(Canvas, MyFont2), Result.Height);
                MaxDescent = Math.Max(MaxDescent, Canvas.FontDescent(MyFont2) + Suby.Offset(Canvas, MyFont2));
            }

            return(new SizeF(x, y));
        }
        public TFlxFormat GetBold(TFlxFormat obj)
        {
            TFlxFont tfont = new TFlxFont();
            tfont.Style = TFlxFontStyles.Bold;

            obj.Font = tfont;

            return obj;
        }
        private int NoColorBold(XlsFile xls, int row, int col)
        {
            TFlxFormat tf4 = xls.GetCellVisibleFormatDef(row, col);
            TFlxFont tfont = new TFlxFont();
            tfont.Style = TFlxFontStyles.Bold;

            tf4.Font = tfont;
            return xls.AddFormat(tf4);
        }
        private int NoColorAndRightBorder(XlsFile xls, int row, int col)
        {
            TFlxFormat tf3 = xls.GetCellVisibleFormatDef(row, col);

            TFlxFont tfont = new TFlxFont();
            tfont.Style = TFlxFontStyles.Bold;
            tf3.Font = tfont;

            TFlxBorders tfBorderF = new TFlxBorders();
            TFlxOneBorder oborder = new TFlxOneBorder();
            oborder.Style = TFlxBorderStyle.Thin;
            tfBorderF.Right = oborder;

            tf3.Borders = tfBorderF;

            return xls.AddFormat(tf3);
        }
        private int ColorBold(XlsFile xls, int row, int col)
        {
            TFlxFormat tf4 = xls.GetCellVisibleFormatDef(row, col);

            TFlxFont tfont = new TFlxFont();
            tfont.Style = TFlxFontStyles.Bold;

            tf4.Font = tfont;

            TFlxFillPattern tfpattern3 = new TFlxFillPattern();
            tfpattern3.BgColor = Colors.LightGray;
            tf4.FillPattern = tfpattern3;

            return xls.AddFormat(tf4);
        }
        private int ColorAndRightBorder(XlsFile xls, int row, int col)
        {
            TFlxFormat tf4 = xls.GetCellVisibleFormatDef(row, col);

            TFlxFont tfont = new TFlxFont();
            tfont.Style = TFlxFontStyles.Bold;
            tf4.Font = tfont;

            TFlxBorders tfBorderF1 = new TFlxBorders();

            TFlxOneBorder oborder1 = new TFlxOneBorder();
            oborder1.Style = TFlxBorderStyle.Thin;

            tfBorderF1.Right = oborder1;

            tf4.Borders = tfBorderF1;

            TFlxFillPattern tfpattern3 = new TFlxFillPattern();
            tfpattern3.BgColor = Colors.LightGray;
            tf4.FillPattern = tfpattern3;

            return xls.AddFormat(tf4);
        }
Example #22
0
 private static real FullGetFont0Width(TFlxFont Fx)
 {
     return(7);
 }
Example #23
0
 private static int FullGetRowHeight(TFlxFont Fx)
 {
     return(0xFF);
 }
Example #24
0
        private static TFlxFontStyles CachedFontStyle; //STATIC*
#endif

        #region Font0Width
        /// <summary>
        /// Returns the width of the 0 font on Excel. Normally this is 7, but can change depending on
        /// the file. The user might modify it by changing Format->Style->Normal.
        /// </summary>
        /// <param name="Workbook"></param>
        /// <returns></returns>
        public static real GetFont0Width(IRowColSize Workbook)
        {
            TFlxFont Fx = Workbook.GetDefaultFont;

            return(GetFont0Width(Fx));
        }