static void EditSeparator(Document document) { #region #EditSeparator document.LoadDocument("Documents//Grimm.docx"); //Check whether the footnotes already have a separator: if (document.Footnotes.HasSeparator(NoteSeparatorType.Separator)) { //Initiate the update session: SubDocument noteSeparator = document.Footnotes.BeginUpdateSeparator(NoteSeparatorType.Separator); //Clear the separator range: noteSeparator.Delete(noteSeparator.Range); //Append a new text: noteSeparator.AppendText("***"); CharacterProperties characterProperties = noteSeparator.BeginUpdateCharacters(noteSeparator.Range); characterProperties.ForeColor = System.Drawing.Color.Blue; noteSeparator.EndUpdateCharacters(characterProperties); //Finalize the update: document.Footnotes.EndUpdateSeparator(noteSeparator); } #endregion #EditSeparator }
//public DxDoc(DxChartFactory factory, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} //public DxDoc(List<DxChartOrder> ordersC, string path, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // _temppath = path; // _projtitle = projtitle; // _datafile = datafile; // _filename = "test.docx"; // filename; // MakeDocx(ordersC); // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} //public DxDoc(DataTable dt_plots, List<string> htmltables, string path, string filename, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // _temppath = path; // _projtitle = projtitle; // _datafile = datafile; // _filename = filename; // MakeDocx(dt_plots, htmltables); // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} //public DxDoc(DataTable dt_plots, DataTable dt_tables, string path, string filename, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // _temppath = path; // _projtitle = projtitle; // _datafile = datafile; // _filename = filename; // MakeDocx(dt_plots, dt_tables); // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} #endregion protected void DocxHeader(DevExpress.XtraRichEdit.API.Native.Document doc, string s1, string s2) { DevExpress.XtraRichEdit.API.Native.Section firstSection = doc.Sections[0]; // Create an empty header. SubDocument newHeader = firstSection.BeginUpdateHeader(); firstSection.EndUpdateHeader(newHeader); // Check whether the document already has a header (the same header for all pages). if (firstSection.HasHeader(DevExpress.XtraRichEdit.API.Native.HeaderFooterType.Primary)) { SubDocument myHeader = firstSection.BeginUpdateHeader(); doc.ChangeActiveDocument(myHeader); doc.CaretPosition = myHeader.CreatePosition(0); string txt = String.Format("{0} p.", s1); DocumentRange range = myHeader.InsertText(myHeader.CreatePosition(0), txt); Field fld = myHeader.Fields.Create(range.End, "PAGE"); // "PAGE \\* ARABICDASH"); myHeader.Fields.Update(); myHeader.Paragraphs.Append(); string user_time = String.Format("{0} {1:MM/dd/yy H:mm}", _creator_netid, System.DateTime.Now); myHeader.AppendText(String.Format("{0} {1}", s2, user_time)); firstSection.EndUpdateHeader(myHeader); } }
static void CreateHeader(Document document) { #region #CreateHeader Section firstSection = document.Sections[0]; // Create an empty header. // Check whether the document already has a header (the same header for all pages). if (!firstSection.HasHeader(HeaderFooterType.Primary)) { SubDocument headerDocument = firstSection.BeginUpdateHeader(); document.ChangeActiveDocument(headerDocument); headerDocument.AppendText("Header"); firstSection.EndUpdateHeader(headerDocument); } #endregion #CreateHeader }
static void SelectCellsAndSplit(Document document) { #region #SelectCellsAndSplit document.LoadDocument("Documents//SelectionCollection.docx", DocumentFormat.OpenXml); Table rootTable = document.Tables[0]; DocumentPosition position10 = rootTable.Rows[0].Cells[1].Range.Start; DocumentPosition position11 = rootTable.Rows[3].LastCell.Range.End; DocumentRange range1 = document.CreateRange(position10, position11.ToInt() - position10.ToInt()); document.Selections.Add(range1); Comment comment = document.Comments.Create(document.Selection, ""); SubDocument commentDoc = comment.BeginUpdate(); commentDoc.AppendText(String.Format("\r\nSelectionCollection \r\ncontains {0} item(s).", document.Selections.Count)); comment.EndUpdate(commentDoc); #endregion #SelectCellsAndSplit }
private void EditTextBoxContent(Document document) { #region #editcontent //Access the text box content SubDocument textBoxDocument = document.Shapes[0].TextBox.Document; //Insert text to the text box textBoxDocument.AppendText("Multimodal, Stochastic Symmetries for E-Commerce"); //Apply formatting to the text box content CharacterProperties cp = textBoxDocument.BeginUpdateCharacters(textBoxDocument.Range); cp.ForeColor = Color.DarkSlateGray; cp.FontName = "Times New Roman"; cp.FontSize = 18; textBoxDocument.EndUpdateCharacters(cp); #endregion #editcontent }
static void AddTextBox(Document document) { #region #AddTextBox document.AppendText("Line One\nLine Two\nLine Three"); Shape myTextBox = document.Shapes.InsertTextBox(document.CreatePosition(15)); myTextBox.HorizontalAlignment = ShapeHorizontalAlignment.Center; // Specify the text box background color. myTextBox.Fill.Color = System.Drawing.Color.WhiteSmoke; // Draw a border around the text box. myTextBox.Line.Color = System.Drawing.Color.Black; myTextBox.Line.Thickness = 1; // Modify text box content. SubDocument textBoxDocument = myTextBox.TextBox.Document; textBoxDocument.AppendText("TextBox Text"); CharacterProperties cp = textBoxDocument.BeginUpdateCharacters(textBoxDocument.Range.Start, 7); cp.ForeColor = System.Drawing.Color.Orange; cp.FontSize = 24; textBoxDocument.EndUpdateCharacters(cp); #endregion #AddTextBox }
static void SelectAndMerge(Document document) { #region #SelectAndMerge document.LoadDocument("Documents//SelectionCollection.docx", DocumentFormat.OpenXml); DocumentRange range1 = document.CreateRange(document.Range.Start, 12); DocumentRange range2 = document.CreateRange(document.Range.Start.ToInt() + 12, 9); DocumentRange range3 = document.CreateRange(document.Range.Start.ToInt() + 21, 3); List <DocumentRange> ranges = new List <DocumentRange>() { range1, range2 }; document.Selections.Add(ranges); Comment comment = document.Comments.Create(document.Selection, ""); SubDocument commentDoc = comment.BeginUpdate(); commentDoc.AppendText(String.Format("\r\nSelectionCollection \r\ncontains {0} item(s).", document.Selections.Count)); comment.EndUpdate(commentDoc); #endregion #SelectAndMerge }
static void EditFootnote(Document document) { #region #EditFootnote document.LoadDocument("Documents//Grimm.docx"); //Access the first fottnote's content: SubDocument footnote = document.Footnotes[0].BeginUpdate(); //Exclude the reference mark and the space after it from the range to be edited: DocumentRange noteTextRange = footnote.CreateRange(footnote.Range.Start.ToInt() + 2, footnote.Range.Length - 2); //Clear the range: footnote.Delete(noteTextRange); //Append a new text: footnote.AppendText("the text is removed"); //Finalize the update: document.Footnotes[0].EndUpdate(footnote); #endregion #EditFootnote }
static void EditSeparator(Document document) { #region #EditSeparator document.LoadDocument("Documents//Grimm.docx"); //Check whether the footnotes already have a separator: if (document.Footnotes.HasSeparator(NoteSeparatorType.Separator)) { //Initiate the update session: SubDocument noteSeparator = document.Footnotes.BeginUpdateSeparator(NoteSeparatorType.Separator); //Clear the separator range: noteSeparator.Delete(noteSeparator.Range); //Append a new text: noteSeparator.AppendText("***"); //Finalize the update: document.Footnotes.EndUpdateSeparator(noteSeparator); } #endregion #EditSeparator }
protected internal MemoryStream ExaminationPlanTemplate() { Document doc = reds.Document; doc.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A4; doc.DefaultCharacterProperties.FontSize = 12; doc.Unit = DevExpress.Office.DocumentUnit.Centimeter; doc.Sections[0].Margins.Bottom = 2; doc.Sections[0].Margins.Top = 2; doc.Sections[0].Margins.Left = 2; doc.Sections[0].Margins.Right = 2; doc.Sections[0].Margins.FooterOffset = 0.8F; doc.Unit = DevExpress.Office.DocumentUnit.Point; Section firstSection = doc.Sections[0]; SubDocument subdoc = firstSection.BeginUpdateHeader(HeaderFooterType.Primary); DocumentRange textRange = subdoc.AppendText("Kezelési Terv"); CharacterProperties cp1 = subdoc.BeginUpdateCharacters(textRange); cp1.Bold = true; cp1.Italic = true; cp1.FontSize = 18; subdoc.EndUpdateCharacters(cp1); subdoc.Paragraphs[0].Alignment = ParagraphAlignment.Center; subdoc.Paragraphs[0].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.Sections[0].EndUpdateHeader(subdoc); doc.Protect("admin"); using (MemoryStream ms = new MemoryStream()) { reds.SaveDocument(ms, DocumentFormat.OpenXml); return(ms); } }
protected internal MemoryStream Billing(string Code, CreateBillM.CompanyData from, CreateBillM.CompanyData to, ObservableCollection <CreateBillM.PrintItem> PrintList, int PriceWithoutVat, int Vat, int PriceWithVat) { Document doc = reds.Document; doc.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A4; doc.DefaultCharacterProperties.FontSize = 11; doc.Unit = DevExpress.Office.DocumentUnit.Centimeter; doc.Sections[0].Margins.Bottom = 2; doc.Sections[0].Margins.Top = 2; doc.Sections[0].Margins.Left = 2; doc.Sections[0].Margins.Right = 2; doc.Sections[0].Margins.FooterOffset = 0.8F; doc.Unit = DevExpress.Office.DocumentUnit.Point; Section firstSection = doc.Sections[0]; SubDocument subdoc = firstSection.BeginUpdateHeader(HeaderFooterType.Primary); DocumentRange textRange = subdoc.AppendText("Számla"); CharacterProperties cp1 = subdoc.BeginUpdateCharacters(textRange); cp1.Bold = true; cp1.Italic = true; cp1.FontSize = 20; subdoc.EndUpdateCharacters(cp1); subdoc.Paragraphs[0].Alignment = ParagraphAlignment.Center; subdoc.Paragraphs[0].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.Sections[0].EndUpdateHeader(subdoc); Section section = doc.Sections[0]; SubDocument subdoc2 = firstSection.BeginUpdateFooter(HeaderFooterType.Primary); Table table2 = subdoc2.Tables.Create(subdoc2.Range.Start, 1, 2); table2.TableLayout = TableLayoutType.Fixed; table2.PreferredWidth = 5000; table2.PreferredWidthType = WidthType.FiftiethsOfPercent; table2.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table2.Borders.Left.LineStyle = TableBorderLineStyle.None; table2.Borders.Right.LineStyle = TableBorderLineStyle.None; table2.Borders.Bottom.LineStyle = TableBorderLineStyle.None; subdoc2.InsertText(table2[0, 0].Range.Start, DateTime.Now.ToString("yyyy. MMMM d.", new CultureInfo("hu-HU"))); DocumentRange range = subdoc2.InsertText(table2[0, 0].Range.Start, "Kiállítás dátuma: "); CharacterProperties cp = subdoc2.BeginUpdateCharacters(range); cp.Bold = true; subdoc2.Paragraphs[0].SpacingBefore = 3; subdoc2.InsertText(table2[0, 1].Range.Start, Code); DocumentRange r = subdoc2.InsertText(table2[0, 1].Range.Start, "Számla azonosító: "); CharacterProperties c = subdoc2.BeginUpdateCharacters(r); c.Bold = true; subdoc2.Paragraphs[1].Alignment = ParagraphAlignment.Right; subdoc2.Paragraphs[1].SpacingBefore = 3; doc.Sections[0].EndUpdateFooter(subdoc2); Table table = doc.Tables.Create(doc.Range.Start, 2, 2); table.TableLayout = TableLayoutType.Fixed; table.PreferredWidth = 5000; table.PreferredWidthType = WidthType.FiftiethsOfPercent; table.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table.Borders.Left.LineStyle = TableBorderLineStyle.None; table.Borders.Right.LineStyle = TableBorderLineStyle.None; table.Borders.Top.LineStyle = TableBorderLineStyle.None; DocumentRange range2 = reds.Document.InsertText(table[0, 0].Range.Start, "Számla kiállító adatai"); CharacterProperties cp2 = reds.Document.BeginUpdateCharacters(range2); cp2.FontSize = 16; cp2.Bold = true; DocumentRange range3 = reds.Document.InsertText(table[0, 1].Range.Start, "Vevő adatai"); CharacterProperties cp3 = reds.Document.BeginUpdateCharacters(range3); cp3.FontSize = 16; cp3.Bold = true; ParagraphProperties props = reds.Document.BeginUpdateParagraphs(table[0, 0].Range); props.SpacingAfter = 2; Table left = doc.Tables.Create(table[1, 0].Range.Start, 1, 1); left.TableLayout = TableLayoutType.Fixed; left.PreferredWidth = 5000; left.PreferredWidthType = WidthType.FiftiethsOfPercent; left.Borders.Left.LineStyle = TableBorderLineStyle.None; left.Borders.Right.LineStyle = TableBorderLineStyle.None; left.Borders.Top.LineStyle = TableBorderLineStyle.None; left.Borders.Bottom.LineStyle = TableBorderLineStyle.None; Table right = doc.Tables.Create(table[1, 1].Range.Start, 1, 1); right.TableLayout = TableLayoutType.Fixed; right.PreferredWidth = 5000; right.PreferredWidthType = WidthType.FiftiethsOfPercent; right.Borders.Left.LineStyle = TableBorderLineStyle.None; right.Borders.Right.LineStyle = TableBorderLineStyle.None; right.Borders.Top.LineStyle = TableBorderLineStyle.None; right.Borders.Bottom.LineStyle = TableBorderLineStyle.None; bool exist1 = false; bool exist2 = false; if (from.WebPage != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "WEB: " + from.WebPage); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "WEB: " + from.WebPage); } } if (to.WebPage != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "WEB: " + to.WebPage); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "WEB: " + to.WebPage); } } if (from.Email != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Email: " + from.Email); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Email: " + from.Email + "\n"); } } if (to.Email != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Email: " + to.Email); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Email: " + to.Email + "\n"); } } if (from.Phone != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Telefon: " + from.Phone); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Telefon: " + from.Phone + "\n"); } } if (to.Phone != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Telefon: " + to.Phone); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Telefon: " + to.Phone + "\n"); } } if (from.InvoiceNumber != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Bankszámlaszám: " + from.InvoiceNumber); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Bankszámlaszám: " + from.InvoiceNumber + "\n"); } } if (to.InvoiceNumber != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Bankszámlaszám: " + to.InvoiceNumber); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Bankszámlaszám: " + to.InvoiceNumber + "\n"); } } if (from.RegistrationNumber != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Cégjegyzékszám: " + from.RegistrationNumber); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Cégjegyzékszám: " + from.RegistrationNumber + "\n"); } } if (to.RegistrationNumber != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Cégjegyzékszám: " + to.RegistrationNumber); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Cégjegyzékszám: " + to.RegistrationNumber + "\n"); } } if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Adószám: " + from.TaxNumber); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Adószám: " + from.TaxNumber + "\n"); } if (to.TaxNumber != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Adószám: " + to.TaxNumber); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Adószám: " + to.TaxNumber + "\n"); } } doc.InsertText(left[0, 0].Range.Start, from.Address + "\n"); if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, to.Address); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, to.Address + "\n"); } doc.InsertText(left[0, 0].Range.Start, from.ZipCode + " " + from.Settlement + "\n"); doc.InsertText(right[0, 0].Range.Start, to.ZipCode + " " + to.Settlement + "\n"); DocumentRange range4 = doc.InsertText(left[0, 0].Range.Start, from.Name + "\n"); ParagraphProperties props2 = reds.Document.BeginUpdateParagraphs(range4); props2.SpacingBefore = 5; props2.SpacingAfter = 3; CharacterProperties cp4 = reds.Document.BeginUpdateCharacters(range4); cp4.Bold = true; cp4.FontSize = 14; DocumentRange range5 = doc.InsertText(right[0, 0].Range.Start, to.Name + "\n"); ParagraphProperties props3 = reds.Document.BeginUpdateParagraphs(range5); props3.SpacingBefore = 5; props3.SpacingAfter = 3; CharacterProperties cp5 = reds.Document.BeginUpdateCharacters(range5); cp5.Bold = true; cp5.FontSize = 14; ParagraphProperties props4 = reds.Document.BeginUpdateParagraphs(range6); ParagraphProperties props5 = reds.Document.BeginUpdateParagraphs(range7); props4.SpacingAfter = 5; props5.SpacingAfter = 5; doc.AppendText("\n\n"); Table table1 = doc.Tables.Create(doc.Range.End, 1, 7); table1.TableLayout = TableLayoutType.Fixed; table1.PreferredWidth = 5000; table1.PreferredWidthType = WidthType.FiftiethsOfPercent; table1.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table1.Borders.Left.LineStyle = TableBorderLineStyle.None; table1.Borders.Right.LineStyle = TableBorderLineStyle.None; table1.Borders.Top.LineStyle = TableBorderLineStyle.None; table1.Borders.Bottom.LineStyle = TableBorderLineStyle.None; table1[0, 0].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 0].PreferredWidth = 1250; table1[0, 0].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 1].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 1].PreferredWidth = 500; table1[0, 1].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 2].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 2].PreferredWidth = 688; table1[0, 2].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 3].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 3].PreferredWidth = 688; table1[0, 3].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 4].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 4].PreferredWidth = 500; table1[0, 4].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 5].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 5].PreferredWidth = 688; table1[0, 5].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 6].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 6].PreferredWidth = 688; table1[0, 6].VerticalAlignment = TableCellVerticalAlignment.Center; DocumentRange r0 = doc.InsertText(table1[0, 0].Range.Start, "Megnevezés"); CharacterProperties c0 = reds.Document.BeginUpdateCharacters(r0); c0.Bold = true; c0.FontSize = 10; DocumentRange r1 = doc.InsertText(table1[0, 1].Range.Start, "Menny."); CharacterProperties c1 = reds.Document.BeginUpdateCharacters(r1); c1.Bold = true; c1.FontSize = 10; ParagraphProperties p1 = doc.BeginUpdateParagraphs(r1); p1.Alignment = ParagraphAlignment.Right; DocumentRange r2 = doc.InsertText(table1[0, 2].Range.Start, "Egységár"); CharacterProperties c2 = reds.Document.BeginUpdateCharacters(r2); c2.Bold = true; c2.FontSize = 10; ParagraphProperties p2 = doc.BeginUpdateParagraphs(r2); p2.Alignment = ParagraphAlignment.Right; DocumentRange r3 = doc.InsertText(table1[0, 3].Range.Start, "Nettó ár"); CharacterProperties c3 = reds.Document.BeginUpdateCharacters(r3); c3.Bold = true; c3.FontSize = 10; ParagraphProperties p3 = doc.BeginUpdateParagraphs(r3); p3.Alignment = ParagraphAlignment.Right; DocumentRange r4 = doc.InsertText(table1[0, 4].Range.Start, "ÁFA"); CharacterProperties c4 = reds.Document.BeginUpdateCharacters(r4); c4.Bold = true; c4.FontSize = 10; ParagraphProperties p4 = doc.BeginUpdateParagraphs(r4); p4.Alignment = ParagraphAlignment.Right; DocumentRange r5 = doc.InsertText(table1[0, 5].Range.Start, "Áfa érték"); CharacterProperties c5 = reds.Document.BeginUpdateCharacters(r5); c5.Bold = true; c5.FontSize = 10; ParagraphProperties p5 = doc.BeginUpdateParagraphs(r5); p5.Alignment = ParagraphAlignment.Right; DocumentRange r6 = doc.InsertText(table1[0, 6].Range.Start, "Bruttó ár"); CharacterProperties c6 = reds.Document.BeginUpdateCharacters(r6); c6.Bold = true; c6.FontSize = 10; ParagraphProperties p6 = doc.BeginUpdateParagraphs(r6); p6.Alignment = ParagraphAlignment.Right; Table table3 = doc.Tables.Create(doc.Range.End, PrintList.Count, 7); table3.TableLayout = TableLayoutType.Fixed; table3.PreferredWidth = 5000; table3.PreferredWidthType = WidthType.FiftiethsOfPercent; table3.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table3.Borders.InsideHorizontalBorder.LineStyle = TableBorderLineStyle.None; table3.Borders.Left.LineStyle = TableBorderLineStyle.None; table3.Borders.Right.LineStyle = TableBorderLineStyle.None; table3[0, 0].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 0].PreferredWidth = 1250; table3[0, 1].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 1].PreferredWidth = 500; table3[0, 2].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 2].PreferredWidth = 688; table3[0, 3].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 3].PreferredWidth = 688; table3[0, 4].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 4].PreferredWidth = 500; table3[0, 5].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 5].PreferredWidth = 688; table3[0, 6].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 6].PreferredWidth = 688; List <DocumentRange> dr = new List <DocumentRange>(); List <ParagraphProperties> ppr = new List <ParagraphProperties>(); List <CharacterProperties> cpr = new List <CharacterProperties>(); for (int i = 0; i < PrintList.Count; i++) { if (i % 2 == 0) { for (int column = 0; column < 7; column++) { table3[i, column].BackgroundColor = ColorTranslator.FromHtml("#E6E6E6"); } } dr.Add(doc.InsertText(table3[i, 0].Range.Start, PrintList[i].Name)); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 0].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 1].Range.Start, PrintList[i].Quantity.ToString())); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 1].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 2].Range.Start, Grouping(PrintList[i].QuantityPrice))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 2].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 3].Range.Start, Grouping(PrintList[i].PriceWithoutVat))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 3].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 4].Range.Start, PrintList[i].Vat.ToString() + " %")); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 4].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 5].Range.Start, Grouping(PrintList[i].VatPrice))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 5].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 6].Range.Start, Grouping(PrintList[i].PriceWithVat))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 6].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Clear(); ppr.Clear(); cpr.Clear(); } Table table4 = doc.Tables.Create(doc.Range.End, 1, 7); table4.TableLayout = TableLayoutType.Fixed; table4.PreferredWidth = 5000; table4.PreferredWidthType = WidthType.FiftiethsOfPercent; table4.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table4.Borders.Left.LineStyle = TableBorderLineStyle.None; table4.Borders.Right.LineStyle = TableBorderLineStyle.None; table4.Borders.Bottom.LineStyle = TableBorderLineStyle.None; table4.Borders.Top.LineStyle = TableBorderLineStyle.None; table4[0, 0].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 0].PreferredWidth = 1250; table4[0, 0].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 1].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 1].PreferredWidth = 500; table4[0, 1].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 2].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 2].PreferredWidth = 688; table4[0, 2].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 3].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 3].PreferredWidth = 688; table4[0, 3].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 4].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 4].PreferredWidth = 500; table4[0, 4].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 5].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 5].PreferredWidth = 688; table4[0, 5].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 6].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 6].PreferredWidth = 688; table4[0, 6].VerticalAlignment = TableCellVerticalAlignment.Bottom; DocumentRange rq0 = doc.InsertText(table4[0, 0].Range.Start, "Összesen:"); CharacterProperties cq0 = reds.Document.BeginUpdateCharacters(rq0); cq0.Bold = true; cq0.FontSize = 10; DocumentRange rq3 = doc.InsertText(table4[0, 3].Range.Start, Grouping(PriceWithoutVat)); CharacterProperties cq3 = reds.Document.BeginUpdateCharacters(rq3); cq3.Bold = true; cq3.FontSize = 10; ParagraphProperties pq3 = doc.BeginUpdateParagraphs(rq3); pq3.Alignment = ParagraphAlignment.Right; pq3.SpacingBefore = 4; DocumentRange rq5 = doc.InsertText(table4[0, 5].Range.Start, Grouping(Vat)); CharacterProperties cq5 = reds.Document.BeginUpdateCharacters(rq5); cq5.Bold = true; cq5.FontSize = 10; ParagraphProperties pq5 = doc.BeginUpdateParagraphs(rq5); pq5.Alignment = ParagraphAlignment.Right; DocumentRange rq6 = doc.InsertText(table4[0, 6].Range.Start, Grouping(PriceWithVat)); CharacterProperties cq6 = reds.Document.BeginUpdateCharacters(rq6); cq6.Bold = true; cq6.FontSize = 10; ParagraphProperties pq6 = doc.BeginUpdateParagraphs(rq6); pq6.Alignment = ParagraphAlignment.Right; doc.AppendText("\n\n"); DocumentRange last = doc.AppendText("Fizetendő: " + Grouping(PriceWithVat) + " Ft"); CharacterProperties lastcp = doc.BeginUpdateCharacters(last); lastcp.Bold = true; lastcp.FontSize = 16; ParagraphProperties lastpp = doc.BeginUpdateParagraphs(last); lastpp.Alignment = ParagraphAlignment.Right; using (MemoryStream ms = new MemoryStream()) { reds.ExportToPdf(ms); return(ms); } }
protected internal MemoryStream Template(bool Type, string companyName, string companyZip, string companySettlement, string companyAddress, string doctorName, int doctorSealNumber, string patientName, string motherName, DateTime birthDate, string TAJ, string patientZip, string patientSettlement, string patientAddress, string examination, string examinationCode) { Document doc = reds.Document; doc.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A4; doc.DefaultCharacterProperties.FontSize = 12; doc.Unit = DevExpress.Office.DocumentUnit.Centimeter; doc.Sections[0].Margins.Bottom = 2; doc.Sections[0].Margins.Top = 2; doc.Sections[0].Margins.Left = 2; doc.Sections[0].Margins.Right = 2; doc.Sections[0].Margins.FooterOffset = 0.8F; doc.Unit = DevExpress.Office.DocumentUnit.Point; SubDocument subdoc = doc.Sections[0].BeginUpdateHeader(HeaderFooterType.Primary); DocumentRange textRange; if (Type) { textRange = subdoc.AppendText("Vizsgálati Lap"); } else { textRange = subdoc.AppendText("Státusz"); } CharacterProperties cp1 = subdoc.BeginUpdateCharacters(textRange); cp1.Bold = true; cp1.Italic = true; cp1.FontSize = 18; subdoc.EndUpdateCharacters(cp1); subdoc.Paragraphs[0].Alignment = ParagraphAlignment.Center; subdoc.Paragraphs[0].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.Sections[0].EndUpdateHeader(subdoc); SubDocument subdoc2 = doc.Sections[0].BeginUpdateFooter(HeaderFooterType.Primary); Table table2 = subdoc2.Tables.Create(subdoc2.Range.Start, 1, 2); table2.TableLayout = TableLayoutType.Fixed; table2.PreferredWidth = 5000; table2.PreferredWidthType = WidthType.FiftiethsOfPercent; table2.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table2.Borders.Left.LineStyle = TableBorderLineStyle.None; table2.Borders.Right.LineStyle = TableBorderLineStyle.None; table2.Borders.Bottom.LineStyle = TableBorderLineStyle.None; subdoc2.InsertText(table2[0, 0].Range.Start, DateTime.Now.ToString("yyyy. MMMM d.", new CultureInfo("hu-HU"))); DocumentRange range = subdoc2.InsertText(table2[0, 0].Range.Start, "Dátum: "); CharacterProperties cp = subdoc2.BeginUpdateCharacters(range); cp.Bold = true; subdoc2.Paragraphs[0].SpacingBefore = 3; subdoc2.InsertText(table2[0, 1].Range.Start, examinationCode); DocumentRange r = subdoc2.InsertText(table2[0, 1].Range.Start, "Azonosító: "); CharacterProperties c = subdoc2.BeginUpdateCharacters(r); c.Bold = true; subdoc2.Paragraphs[1].Alignment = ParagraphAlignment.Right; subdoc2.Paragraphs[1].SpacingBefore = 3; doc.Sections[0].EndUpdateFooter(subdoc2); Table table = doc.Tables.Create(doc.CaretPosition, 2, 2); table.TableLayout = TableLayoutType.Fixed; table.PreferredWidth = 5000; table.PreferredWidthType = WidthType.FiftiethsOfPercent; table.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table.Borders.Left.LineStyle = TableBorderLineStyle.None; table.Borders.Right.LineStyle = TableBorderLineStyle.None; doc.InsertText(table[0, 0].Range.Start, "\t" + companyAddress); doc.InsertText(table[0, 0].Range.Start, " Címe: " + companyZip + " " + companySettlement + "\n"); doc.InsertText(table[0, 0].Range.Start, " Neve: " + companyName + "\n"); DocumentRange range1 = doc.InsertText(table[0, 0].Range.Start, "Intézmény\n"); CharacterProperties cp2 = doc.BeginUpdateCharacters(range1); cp2.Bold = true; cp2.FontSize = 16; doc.EndUpdateCharacters(cp2); doc.Paragraphs[0].SpacingBefore = 6; doc.Paragraphs[3].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.InsertText(table[0, 1].Range.Start, " Pecsétszáma: " + doctorSealNumber); doc.InsertText(table[0, 1].Range.Start, " Neve: " + doctorName + "\n"); DocumentRange range2 = doc.InsertText(table[0, 1].Range.Start, "Orvos\n"); CharacterProperties cp3 = doc.BeginUpdateCharacters(range2); cp3.Bold = true; cp3.FontSize = 16; doc.EndUpdateCharacters(cp3); doc.Paragraphs[4].SpacingBefore = 6; doc.InsertText(table[1, 0].Range.Start, " Születési ideje: " + birthDate.ToString("yyyy. MMMM d.", new CultureInfo("hu-HU"))); doc.InsertText(table[1, 0].Range.Start, " Anyja neve: " + motherName + "\n"); doc.InsertText(table[1, 0].Range.Start, " Neve: " + patientName + "\n"); DocumentRange range3 = doc.InsertText(table[1, 0].Range.Start, "Páciens\n"); CharacterProperties cp4 = doc.BeginUpdateCharacters(range3); cp4.Bold = true; cp4.FontSize = 16; doc.EndUpdateCharacters(cp4); doc.Paragraphs[7].SpacingBefore = 6; doc.Paragraphs[10].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.InsertText(table[1, 1].Range.Start, "\t" + patientAddress); doc.InsertText(table[1, 1].Range.Start, " Lakcíme: " + patientZip + " " + patientSettlement + "\n"); doc.InsertText(table[1, 1].Range.Start, " TAJ száma: " + TAJ + "\n"); DocumentRange range4 = doc.InsertText(table[1, 1].Range.Start, "\n"); CharacterProperties cp5 = doc.BeginUpdateCharacters(range4); cp5.Bold = true; cp5.FontSize = 16; doc.EndUpdateCharacters(cp5); doc.Paragraphs[11].SpacingBefore = 6; if (Type) { DocumentRange range5 = doc.AppendText(" Vizsgálat: "); CharacterProperties cp6 = doc.BeginUpdateCharacters(range5); cp6.Bold = true; cp6.FontSize = 16; doc.Paragraphs[15].SpacingBefore = 6; doc.Paragraphs[15].LineSpacingType = ParagraphLineSpacing.Sesquialteral; DocumentRange range6 = doc.AppendText(examination); CharacterProperties cp7 = doc.BeginUpdateCharacters(range6); cp7.Bold = false; cp7.FontSize = 12; } doc.Paragraphs.Append(); doc.Paragraphs[Type ? 16 : 15].SpacingBefore = 0; doc.Paragraphs[Type ? 16 : 15].LineSpacingType = ParagraphLineSpacing.Single; doc.AppendText(" "); RangePermissionCollection rpc = doc.BeginUpdateRangePermissions(); RangePermission rangePermission = new RangePermission(doc.Paragraphs[16].Range); rangePermission.UserName = "******"; rpc.Add(rangePermission); doc.EndUpdateRangePermissions(rpc); doc.Protect("admin"); using (MemoryStream ms = new MemoryStream()) { reds.SaveDocument(ms, DocumentFormat.OpenXml); return(ms); } }
protected virtual void SetHeaderFooterOptions(Document book, HeaderFooterKind headerFooterKind, string text, HeaderFooterOptions options) { options ??= new HeaderFooterOptions(); Section section; int sectionNum = options.SectionNum ?? -1; if (sectionNum > 0 && sectionNum <= book.Sections.Count) { section = book.Sections[sectionNum - 1]; } else if (sectionNum < 0 && -sectionNum <= book.Sections.Count) { section = book.Sections[book.Sections.Count - (-sectionNum)]; } else { throw new Exception("Invalid SectionNum."); } SubDocument document = null; DocumentRange range; var type = options.Type; try { switch (headerFooterKind) { case HeaderFooterKind.Header: if (options.LinkToNext) { section.LinkHeaderToNext((DevExpress.XtraRichEdit.API.Native.HeaderFooterType)type); } if (options.LinkToPrevious) { section.LinkHeaderToPrevious((DevExpress.XtraRichEdit.API.Native.HeaderFooterType)type); } document = section.BeginUpdateHeader((DevExpress.XtraRichEdit.API.Native.HeaderFooterType)type); break; case HeaderFooterKind.Footer: if (options.LinkToNext) { section.LinkFooterToNext((DevExpress.XtraRichEdit.API.Native.HeaderFooterType)type); } if (options.LinkToPrevious) { section.LinkFooterToPrevious((DevExpress.XtraRichEdit.API.Native.HeaderFooterType)type); } document = section.BeginUpdateFooter((DevExpress.XtraRichEdit.API.Native.HeaderFooterType)type); break; default: throw new Exception("Invalid DocumentType."); } document.Delete(document.Range); if (options.Html) { //var insertOptions = string.IsNullOrWhiteSpace(ParagraphStyle) ? InsertOptions.KeepSourceFormatting : InsertOptions.UseDestinationStyles; var insertOptions = InsertOptions.KeepSourceFormatting; if (options.UseDestinationStyles) { insertOptions = InsertOptions.UseDestinationStyles; } if (options.KeepSourceFormatting) { insertOptions = InsertOptions.KeepSourceFormatting; } range = document.AppendHtmlText(text, insertOptions); } else { range = document.AppendText(text); } if (!string.IsNullOrWhiteSpace(options.CharacterStyle)) { var style = book.CharacterStyles[options.CharacterStyle] ?? throw new Exception($"Character style '{options.CharacterStyle}' does not exist."); var cp = document.BeginUpdateCharacters(range); try { cp.Style = style; } finally { document.EndUpdateCharacters(cp); } } if (!string.IsNullOrWhiteSpace(options.ParagraphStyle)) { var style = book.ParagraphStyles[options.ParagraphStyle] ?? throw new Exception($"Paragraph style '{options.ParagraphStyle}' does not exist."); var pp = document.BeginUpdateParagraphs(range); try { pp.Style = style; } finally { document.EndUpdateParagraphs(pp); } } if (options.ExpandFields) { ExpandFieldsInBookRange(range, Host?.Spreadsheet?.Workbook); } } finally { if (document != null) { switch (headerFooterKind) { case HeaderFooterKind.Header: section.EndUpdateHeader(document); break; case HeaderFooterKind.Footer: section.EndUpdateFooter(document); break; } } } }
protected virtual void SetupHeaderFooter(Document book) { Section section; int sectionNum = SectionNum ?? -1; if (sectionNum > 0 && sectionNum <= book.Sections.Count) { section = book.Sections[sectionNum - 1]; } else if (sectionNum < 0 && -sectionNum <= book.Sections.Count) { section = book.Sections[book.Sections.Count - (-sectionNum)]; } else { throw new Exception("Invalid SectionNum."); } SubDocument document = null; DocumentRange range; var type = Type; try { switch (HeaderFooter) { case DocumentType.Header: if (LinkToNext) { section.LinkHeaderToNext(type); } if (LinkToPrevious) { section.LinkHeaderToPrevious(type); } document = section.BeginUpdateHeader(type); break; case DocumentType.Footer: if (LinkToNext) { section.LinkFooterToNext(type); } if (LinkToPrevious) { section.LinkFooterToPrevious(type); } document = section.BeginUpdateFooter(type); break; default: throw new Exception("Invalid DocumentType."); } document.Delete(document.Range); if (Html) { //var insertOptions = string.IsNullOrWhiteSpace(ParagraphStyle) ? InsertOptions.KeepSourceFormatting : InsertOptions.UseDestinationStyles; var insertOptions = InsertOptions.KeepSourceFormatting; if (UseDestinationStyles) { insertOptions = InsertOptions.UseDestinationStyles; } if (KeepSourceFormatting) { insertOptions = InsertOptions.KeepSourceFormatting; } range = document.AppendHtmlText(Text, insertOptions); } else { range = document.AppendText(Text); } if (!string.IsNullOrWhiteSpace(CharacterStyle)) { var style = book.CharacterStyles[CharacterStyle] ?? throw new Exception($"Character style '{CharacterStyle}' does not exist."); var cp = document.BeginUpdateCharacters(range); try { cp.Style = style; } finally { document.EndUpdateCharacters(cp); } } if (!string.IsNullOrWhiteSpace(ParagraphStyle)) { var style = book.ParagraphStyles[ParagraphStyle] ?? throw new Exception($"Paragraph style '{ParagraphStyle}' does not exist."); var pp = document.BeginUpdateParagraphs(range); try { pp.Style = style; } finally { document.EndUpdateParagraphs(pp); } } if (ExpandFields) { ExpandFieldsInBookRange(range, HostSpreadsheet); } } finally { if (document != null) { switch (HeaderFooter) { case DocumentType.Header: section.EndUpdateHeader(document); break; case DocumentType.Footer: section.EndUpdateFooter(document); break; } } } }