public void AddTable(int rows, int cols, string styleStr) { m_table = m_section.AddTable(); m_table.ResetCells(rows, cols); m_table.TableFormat.Borders.BorderType = SfUtils.String2BorderStyle(styleStr); m_table.TableFormat.IsAutoResized = true; }
protected override Variable Evaluate(ParsingScript script) { List <Variable> args = script.GetFunctionArgs(); Utils.CheckArgs(args.Count, 3, m_name); SfPdf pdf = args[0] as SfPdf; Utils.CheckNotNull(pdf, m_name, script); //m_grapics.DrawLine(pen, x1, y1, x2, y2); //m_grapics.DrawRectangle(color, x, y, w, h); //m_grapics.DrawPie(pen, x, y, w, h, startAngle, swipeAngle); int x = Utils.GetSafeInt(args, 1); int y = Utils.GetSafeInt(args, 2); int w = Utils.GetSafeInt(args, 3); int h = Utils.GetSafeInt(args, 4); string colorStr = Utils.GetSafeString(args, 5, "black"); PdfBrush color = SfUtils.String2PdfColor(colorStr); float startAngle = (float)Utils.GetSafeDouble(args, 6); float sweepAngle = (float)Utils.GetSafeDouble(args, 7); float lineWidth = (float)Utils.GetSafeDouble(args, 8); pdf.Init(); pdf.AddPie(x, y, w, h, startAngle, sweepAngle, color, lineWidth); ParserFunction.UpdateFunction(pdf); return(pdf); }
public void ApplyStyle(string styleStr, string alignmentStr) { CheckParagraph(); var style = SfUtils.String2WordStyle(styleStr); if (style != BuiltinStyle.NoStyle) { m_paragraph.ApplyStyle(style); } else { m_paragraph.ApplyStyle(styleStr); } var alignment = SfUtils.String2HorizontalAlignment(alignmentStr); m_paragraph.ParagraphFormat.HorizontalAlignment = alignment; }
public void AddTextRange(string text, string font, float fontSize, string fontColor = null, string bgColor = null) { CheckParagraph(); var textRange = m_paragraph.AppendText(text) as WTextRange; textRange.CharacterFormat.FontSize = fontSize; textRange.CharacterFormat.FontName = font; m_paragraph.BreakCharacterFormat.FontSize = fontSize; if (!string.IsNullOrEmpty(fontColor)) { textRange.CharacterFormat.TextColor = SfUtils.String2Color(fontColor); } if (!string.IsNullOrEmpty(bgColor)) { textRange.CharacterFormat.TextBackgroundColor = SfUtils.String2Color(bgColor); } }
public void AddImage(string imagePath, float horizontalPosition = 0f, float verticalPosition = 0f, string textWrap = "InFrontOfText", string horizontalOrigin = "Margin", string verticalOrigin = "Margin", float widthScale = 20f, float heightScale = 20f) { CheckParagraph(); Stream imageStream = UTILS.ImageToStream(imagePath); WPicture picture = m_paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = SfUtils.String2TextWrappingStyle(textWrap); picture.HorizontalOrigin = SfUtils.String2HorizontalOrigin(horizontalOrigin); picture.HorizontalPosition = horizontalPosition; picture.VerticalOrigin = SfUtils.String2VerticalOrigin(verticalOrigin); picture.VerticalPosition = verticalPosition; picture.WidthScale = widthScale; picture.HeightScale = heightScale; }
protected override Variable Evaluate(ParsingScript script) { List <Variable> args = script.GetFunctionArgs(); Utils.CheckArgs(args.Count, 3, m_name); SfPdf pdf = args[0] as SfPdf; Utils.CheckNotNull(pdf, m_name, script); string text = Utils.GetSafeString(args, 1); int x = Utils.GetSafeInt(args, 2); int y = Utils.GetSafeInt(args, 3); string colorStr = Utils.GetSafeString(args, 4, "black"); PdfBrush color = SfUtils.String2PdfColor(colorStr); pdf.Init(); pdf.AddText(text, x, y, color); ParserFunction.UpdateFunction(pdf); return(pdf); }
public void SetValue(string cell, string option, string value) { Init(); switch (option) { case "text": m_sheet.Range[cell].Text = value; break; case "number": m_sheet.Range[cell].Number = Utils.ConvertToDouble(value); break; case "number_format": m_sheet.Range[cell].NumberFormat = value; break; case "date_time": m_sheet.Range[cell].DateTime = DateTime.Parse(value); break; case "merge": m_sheet.Range[cell].Merge(Utils.ConvertToBool(value)); break; case "formula": m_sheet.Range[cell].Formula = value; break; case "col_width": m_sheet.Range[cell].ColumnWidth = Utils.ConvertToDouble(value); break; case "row_height": m_sheet.Range[cell].RowHeight = Utils.ConvertToDouble(value); break; case "include_border": m_sheet.Range[cell].CellStyle.IncludeBorder = Utils.ConvertToBool(value); break; case "wrap_text": m_sheet.Range[cell].WrapText = Utils.ConvertToBool(value); break; case "horizontal_alignment": switch (value) { case "center": m_sheet.Range[cell].HorizontalAlignment = ExcelHAlign.HAlignCenter; break; case "left": m_sheet.Range[cell].HorizontalAlignment = ExcelHAlign.HAlignLeft; break; case "right": m_sheet.Range[cell].HorizontalAlignment = ExcelHAlign.HAlignRight; break; case "fill": m_sheet.Range[cell].HorizontalAlignment = ExcelHAlign.HAlignFill; break; case "justify": m_sheet.Range[cell].HorizontalAlignment = ExcelHAlign.HAlignJustify; break; } break; case "vertical_alignment": switch (value) { case "center": m_sheet.Range[cell].VerticalAlignment = ExcelVAlign.VAlignCenter; break; case "top": m_sheet.Range[cell].VerticalAlignment = ExcelVAlign.VAlignTop; break; case "bottom": m_sheet.Range[cell].VerticalAlignment = ExcelVAlign.VAlignBottom; break; case "fill": m_sheet.Range[cell].VerticalAlignment = ExcelVAlign.VAlignDistributed; break; case "justify": m_sheet.Range[cell].VerticalAlignment = ExcelVAlign.VAlignJustify; break; } break; case "bold": m_sheet.Range[cell].CellStyle.Font.Bold = Utils.ConvertToBool(value); break; case "font_name": m_sheet.Range[cell].CellStyle.Font.FontName = value; break; case "font_size": m_sheet.Range[cell].CellStyle.Font.Size = Utils.ConvertToDouble(value); break; case "font_color": var color = SfUtils.ConvertToColor(value); if (color != COLOR.Color.Empty) { m_sheet.Range[cell].CellStyle.Font.RGBColor = color; } else { m_sheet.Range[cell].CellStyle.Font.Color = SfUtils.GetColor(value); } break; case "color": color = SfUtils.ConvertToColor(value); if (color != COLOR.Color.Empty) { m_sheet.Range[cell].CellStyle.Color = color; } else { m_sheet.Range[cell].CellStyle.Color = COLOR.Color.FromName(SfUtils.GetColor(value).ToString()); } break; default: Console.WriteLine("No action for {0}", option); break; } }