예제 #1
0
        public static void addTable(List <WordEntity> words)
        {
            //创建一个Document类实例,并添加section
            Document doc     = new Document();
            Section  section = doc.AddSection();

            //添加表格
            Table table = section.AddTable(true);

            //添加表格第1行
            TableRow row1 = table.AddRow();

            //添加第1个单元格到第1行
            TableCell cell1 = row1.AddCell();

            cell1.AddParagraph().AppendText("编码");

            //添加第2个单元格到第1行
            TableCell cell2 = row1.AddCell();

            cell2.AddParagraph().AppendText("英文描述");

            //添加第3个单元格到第1行
            TableCell cell3 = row1.AddCell();

            cell3.AddParagraph().AppendText("中文描述");



            foreach (WordEntity w in words)
            {
                //添加表格第2行
                TableRow row2 = table.AddRow(true, false);

                //添加第6个单元格到第2行
                TableCell cell6 = row2.AddCell();
                cell6.AddParagraph().AppendText(w.origin);

                //添加第7个单元格到第2行
                TableCell cell7 = row2.AddCell();
                cell7.AddParagraph().AppendText(w.en_origin);

                //添加第8个单元格到第2行
                TableCell cell8 = row2.AddCell();
                cell8.AddParagraph().AppendText(w.fanyi_res);
            }

            //table.AutoFit()

            table.AutoFit(AutoFitBehaviorType.AutoFitToWindow);

            //保存文档
            doc.SaveToFile(@"d:\Table.docx");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a document
            Document document = new Document();

            //Load file
            document.LoadFromFile(@"..\..\..\..\..\..\Data\TableSample.docx");
            Section section = document.Sections[0];
            Table   table   = section.Tables[0] as Table;

            //Delete the seventh row
            table.Rows.RemoveAt(7);

            //Add a row and insert it into specific position
            TableRow row = new TableRow(document);

            for (int i = 0; i < table.Rows[0].Cells.Count; i++)
            {
                TableCell tc        = row.AddCell();
                Paragraph paragraph = tc.AddParagraph();
                paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
                paragraph.AppendText("Added");
            }
            table.Rows.Insert(2, row);
            //Add a row at the end of table
            table.AddRow();

            //Save to file and launch it
            document.SaveToFile("AddDeleteRow.docx", FileFormat.Docx);
            FileViewer("AddDeleteRow.docx");
        }
예제 #3
0
        /// <summary>
        /// Add horrizontal key values to the specified output Row
        /// </summary>
        /// <param name="horizontalPreviousValues">
        /// A map of {key,  previous value of key}
        /// </param>
        /// <param name="dimension">
        /// The current key
        /// </param>
        /// <param name="outputRow">
        /// The row to add the key values
        /// </param>
        /// <param name="currentValue">
        /// The current value
        /// </param>
        /// <param name="model">
        /// The dataset model
        /// </param>
        private void AddHorrizontalKeyValues(
            IDictionary <string, TableCell> horizontalPreviousValues,
            string dimension,
            TableRow outputRow,
            string currentValue,
            IDataSetModel model)
        {
            TableCell oldValue;

            if (horizontalPreviousValues.TryGetValue(dimension, out oldValue) && oldValue != null &&
                string.Equals(currentValue, oldValue.SdmxValue))
            {
                oldValue.ColumnSpan++;
            }
            else
            {
                var    tableCell = new TableCell();
                string text      = this.GetLocalizedName(dimension, currentValue);
                tableCell.SetupDisplayText(
                    currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput);
                tableCell.AddClass(HtmlClasses.HorizontalKeyValue);
                outputRow.AddCell(tableCell);
                horizontalPreviousValues[dimension] = tableCell;
            }
        }
		public override bool LoadTableData (TableDescription TableDataContent)
			{
			TableDataContent.NameID = "Personen " + NameID;
			TableDataContent.HeadLine = String.Format ("Wahlberechtigte mit den Familiennamen von {0} ", NameID);

			int RunningRowIndex = 0;
			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Block" });
			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Stiege" });
			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Stock/Türe" });
			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Name" });
			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Vorname" });
			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Anz.Chips" });
			foreach (WahlberechtigtInStiege RowEntry in ItemsSource)
				{
				TableRow NewRow = new TableRow();
				NewRow.FirstCellIsRowHeader = true;
				NewRow.AddCell(new TableCell() { Text = RowEntry.Block });
				NewRow.AddCell(new TableCell() { Text = RowEntry.Stiege });
				NewRow.AddCell(new TableCell() { Text = RowEntry.StockTuere });
				NewRow.AddCell(new TableCell() { Text = RowEntry.Name });
				NewRow.AddCell(new TableCell() { Text = RowEntry.Vorname });
				NewRow.AddCell(new TableCell() { Text = Convert.ToString(RowEntry.NumberOfFamilyMember) });
				TableDataContent.Rows.AddRow (NewRow);
				}
			return true;
			}
예제 #5
0
        /// <summary>
        /// Create and setup the titles for horizontal dimensions
        /// </summary>
        /// <param name="model">
        /// The DataSetModel to use
        /// </param>
        /// <param name="horizontalRows">
        /// The horizontal map to add the titles to
        /// </param>
        /// <param name="horizontalOrderedRows">
        /// The list of rows
        /// </param>
        private void CreateHorizontalTitles(
            IDataSetModel model,
            IDictionary <string, TableRow> horizontalRows,
            ICollection <TableRow> horizontalOrderedRows)
        {
            foreach (string dim in model.HorizontalKeys)
            {
                var row = new TableRow();
                row.AddClass(HtmlClasses.HorizontalKeys);

                // First cell is the title, which spawns over all columns used for vertical keys...
                TableCell tableCell = this.CreateTitle(model.AllValidKeys[dim], dim, "hkeytitle");
                tableCell.SetColSpan(Math.Max(1, model.VerticalKeys.Count));
                row.AddCell(tableCell);
                horizontalRows.Add(dim, row);
                horizontalOrderedRows.Add(row);
            }
        }
예제 #6
0
        /// <summary>
        /// Add vertical key values to the specified output Row
        /// </summary>
        /// <param name="verticalPreviousValues">
        /// A map of {key,  previous value of key}
        /// </param>
        /// <param name="dimension">
        /// The current key
        /// </param>
        /// <param name="outputRow">
        /// The row to add the key values
        /// </param>
        /// <param name="currentValue">
        /// The current value
        /// </param>
        /// <param name="model">
        /// The dataset model
        /// </param>
        private void AddVerticalKeyValues2(
            IDictionary <string, TableCell> verticalPreviousValues,
            string dimension,
            TableRow outputRow,
            string currentValue,
            IDataSetModel model)
        {
            var tableCell = new TableCell {
                Text = currentValue
            };

            tableCell.AddClass(HtmlClasses.VerticalKeyValue);
            string text = this.GetLocalizedName(dimension, currentValue);

            tableCell.SetupDisplayText(
                currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput);
            outputRow.AddCell(tableCell);
            verticalPreviousValues[dimension] = tableCell;
        }
예제 #7
0
        protected void RenderHeadingRow(List <string> headings, bool doNotPrettify = false)
        {
            var displayHeadings = headings;

            if (PrettifyColumnHeaders && !doNotPrettify)
            {
                displayHeadings = displayHeadings.Select(h => h.SplitByCapitals().ToTitleCase()).ToList();
            }

            // create the header row
            headerRow = Instantiate <TableRow>(templateHeaderRow, "Header Row");
            table.AddRow(headerRow);

            // create the header cells
            foreach (var heading in displayHeadings)
            {
                var headingCell = Instantiate <TableCell>(templateHeaderCell, "Header Cell");
                headerRow.AddCell(headingCell);

                var text = headingCell.GetComponentInChildren <Text>();
                text.text = heading;
            }
        }
		public override bool LoadTableData(TableDescription TableDataContent)
			{
			TableDataContent.NameID = "Wahlberechtigte " + NameID;
			TableDataContent.HeadLine = String.Format("Wahlberechtigte {0} ", NameID);

			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = String.Empty });
			foreach (String KurzWahlBezeichnung in Years)
				{
				TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = KurzWahlBezeichnung });
				}
			foreach (WahlberechtigtSummen RowEntry in ItemsSource)
				{
				TableRow NewRow = new TableRow();
				NewRow.FirstCellIsRowHeader = true;
				NewRow.AddCell(new TableCell() { Text = Convert.ToString (RowEntry.Block) });
				foreach (WahlberechtigtSummen WahlEntry in RowEntry.WahlberechtigtJeVergleichsWahl)
					{
					NewRow.AddCell(new TableCell() { Text = Convert.ToString(WahlEntry.NumberOfChips) });
					}
				TableDataContent.Rows.AddRow(NewRow);
				}
			return true;
			}
예제 #9
0
        public void UpdateDisplay()
        {
            // don't do anything if we aren't actually active in the hierarchy
            // (basically, we're either inactive or a prefab)
            if (!this.gameObject.activeInHierarchy)
            {
                return;
            }

            if (Config.Sizing.OverrideTransformHeight)
            {
                Ref_DatePickerTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Config.Sizing.PreferredHeight);
            }

            UpdateBorder();
            UpdateHeader();
            UpdateWeekDayHeaders();
            UpdateDaySection();

            // Free all buttons in the pool
            buttonPool.FreeAll();

            // Clear existing data
            Ref_DayTable.ClearRows();

            // Day Names
            var dayNameRow = Ref_DayTable.AddRow(0);

            dayNameRow.dontUseTableRowBackground = true;

            // Empty cell if we're showing the Week Numbers column
            if (Config.WeekDays.ShowWeekNumbers)
            {
                var header = Instantiate(Ref_Template_DayName);
                dayNameRow.AddCell(header.Cell);

                Ref_DayTable.ColumnWidths[0] = Config.WeekDays.WeekNumberColumnWidth;
            }
            else
            {
                Ref_DayTable.ColumnWidths[0] = 0;
            }

            var dayNames = DatePickerUtilities.GetAbbreviatedDayNames();

            foreach (var dayName in dayNames)
            {
                var header = Instantiate(Ref_Template_DayName);
                dayNameRow.AddCell(header.Cell);

                header.HeaderText.text = dayName;
            }

            // Validate our Date Range (if necessary. This method will output an error message if we fail)
            bool dateRangeValid = Config.DateRange.Validate();

            // Dates
            var      days       = DatePickerUtilities.GetDateRangeForDisplay(VisibleDate.Date);
            TableRow row        = null;
            int      weekNumber = 1;

            DateTimeFormatInfo currentDateTimeFormatInfo = DateTimeFormatInfo.CurrentInfo;

            foreach (var day in days)
            {
                if (day.DayOfWeek == DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek)
                {
                    row = Ref_DayTable.AddRow(0);

                    if (Config.WeekDays.ShowWeekNumbers)
                    {
                        if (Config.WeekDays.WeekNumberMode == WeekNumberMode.WeekOfYear)
                        {
                            weekNumber = currentDateTimeFormatInfo.Calendar.GetWeekOfYear(day, Config.WeekDays.CalendarWeekRule, currentDateTimeFormatInfo.FirstDayOfWeek);
                        }

                        var weekNumberCell = Instantiate(Ref_Template_DayName);
                        row.AddCell(weekNumberCell.Cell);

                        weekNumberCell.HeaderText.text = weekNumber.ToString();

                        weekNumber++;
                    }
                }

                if (!Config.Misc.ShowDatesInOtherMonths && !DatePickerUtilities.DateFallsWithinMonth(day, VisibleDate))
                {
                    // add an empty cell
                    row.AddCell();
                }
                else
                {
                    var dayType = GetDayTypeForDate(day);
                    var dayItem = buttonPool.GetButton(dayType);

                    //var dayItem = Instantiate(GetDayTemplateForDate(day));
                    row.AddCell(dayItem.Cell);

                    dayItem.Text.text           = day.Day.ToString();
                    dayItem.DatePicker          = this;
                    dayItem.Date                = day;
                    dayItem.name                = day.ToDateString();
                    dayItem.IsTemplate          = false;
                    dayItem.Button.interactable = true;

                    if (dateRangeValid) // if the date range is not valid, then don't attempt to use it
                    {
                        if ((Config.DateRange.RestrictFromDate && day.CompareTo(Config.DateRange.FromDate) < 0) ||
                            (Config.DateRange.RestrictToDate && day.CompareTo(Config.DateRange.ToDate) > 0))
                        {
                            dayItem.Button.interactable = false;
                        }
                    }
                }
            }

            if (Ref_InputField != null && Ref_InputFieldContainer != null && Ref_InputFieldToggleButtonCell != null)
            {
                Ref_InputField.text = SelectedDate.HasValue ? SelectedDate.Date.ToString(Config.Format.DateFormat) : "";
                if (Ref_ScreenOverlay != null)
                {
                    Ref_ScreenOverlay.color = Config.Modal.ScreenOverlayColor;
                }

                var valueBefore = Ref_InputFieldContainer.ColumnWidths.ToList();

                if (Config.InputField.ShowToggleButton)
                {
                    Ref_InputFieldContainer.ColumnWidths = new List <float> {
                        0, Config.InputField.ToggleButtonWidth
                    };
                    Ref_InputFieldToggleButtonCell.gameObject.SetActive(true);
                }
                else
                {
                    Ref_InputFieldContainer.ColumnWidths = new List <float> {
                        0
                    };
                    Ref_InputFieldToggleButtonCell.gameObject.SetActive(false);
                }

                if (!valueBefore.SequenceEqual(Ref_InputFieldContainer.ColumnWidths))
                {
                    Ref_InputFieldContainer.UpdateLayout();
                }
            }
        }
예제 #10
0
        private TableRow CreateAttributeRow(string concept, string code, string codeDesc, bool highlighted = false)
        {
            TableRow tr = new TableRow();
            if (highlighted) tr.AddClass(HtmlClasses.ExtraInfoTableRowHighlighted);

            TableCell cell_concept = new TableCell(concept);
            cell_concept.AddClass(HtmlClasses.ExtraInfoTableLabelConcept);

            TableCell cell_concept_value = new TableCell(string.Format("[{0}] - {1}", code, codeDesc));
            cell_concept_value.AddClass(HtmlClasses.ExtraInfoTableLabelConceptValue);

            tr.AddCell(cell_concept);
            tr.AddCell(cell_concept_value);

            return tr;
        }
예제 #11
0
        private void Create(string TableName, List <Field> fields, bool IsUseTableName2WordName = false)
        {
            Document document = new Document();
            Section  section  = document.AddSection();


            //创建表
            Table table = section.AddTable(true);


            table.ResetCells(2, 5);

            table.ApplyHorizontalMerge(0, 1, 4);

            TableRow rowHeader = table.Rows[0];

            rowHeader.IsHeader = true;

            UpdateCell(rowHeader.Cells[0], "表名", true);

            UpdateCell(rowHeader.Cells[1], TableName, fontSize: 10);


            TableRow row = table.Rows[1];

            row.IsHeader = true;

            UpdateCell(row.Cells[0], "列名", true);
            UpdateCell(row.Cells[1], "数据类型", true);
            UpdateCell(row.Cells[2], "空/非空", true);
            UpdateCell(row.Cells[3], "约束条件", true);
            UpdateCell(row.Cells[4], "说明", true);



            foreach (var field in fields)
            {
                TableRow row1 = new TableRow(document);
                UpdateCell(row1.AddCell(true), field.Name);
                UpdateCell(row1.AddCell(true), field.Type);
                UpdateCell(row1.AddCell(true), field.NullDesc);
                UpdateCell(row1.AddCell(true), field.PKDesc);
                UpdateCell(row1.AddCell(true), string.Empty);
                table.Rows.Add(row1);
            }

            TableRow rowBottom = new TableRow(document);

            UpdateCell(rowBottom.AddCell(true), "补充说明", true);

            UpdateCell(rowBottom.AddCell(true), string.Empty);
            UpdateCell(rowBottom.AddCell(true), string.Empty);
            UpdateCell(rowBottom.AddCell(true), string.Empty);
            UpdateCell(rowBottom.AddCell(true), string.Empty);

            table.Rows.Add(rowBottom);

            table.ApplyHorizontalMerge(table.Rows.Count - 1, 1, 4);


            if (IsUseTableName2WordName)
            {
                document.SaveToFile($"{TableName}.docx");

                System.Diagnostics.Process.Start($"{TableName}.docx");
            }
            else
            {
                document.SaveToFile("WordTable.docx");

                System.Diagnostics.Process.Start("WordTable.docx");
            }
        }
예제 #12
0
 /// <summary>
 /// Add vertical key values to the specified output Row
 /// </summary>
 /// <param name="verticalPreviousValues">
 /// A map of {key,  previous value of key} 
 /// </param>
 /// <param name="dimension">
 /// The current key
 /// </param>
 /// <param name="outputRow">
 /// The row to add the key values
 /// </param>
 /// <param name="currentValue">
 /// The current value
 /// </param>
 /// <param name="model">
 /// The dataset model
 /// </param>
 private void AddVerticalKeyValues2(
     IDictionary<string, TableCell> verticalPreviousValues, 
     string dimension, 
     TableRow outputRow, 
     string currentValue, 
     IDataSetModel model)
 {
     var tableCell = new TableCell { Text = currentValue };
     tableCell.AddClass(HtmlClasses.VerticalKeyValue);
     string text = this.GetLocalizedName(dimension, currentValue);
     tableCell.SetupDisplayText(
         currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput);
     outputRow.AddCell(tableCell);
     verticalPreviousValues[dimension] = tableCell;
 }
예제 #13
0
        /// <summary>
        /// Add vertical key values to the specified output Row
        /// </summary>
        /// <param name="verticalPreviousValues">
        /// A map of {key,  previous value of key} 
        /// </param>
        /// <param name="dimension">
        /// The current key
        /// </param>
        /// <param name="outputRow">
        /// The row to add the key values
        /// </param>
        /// <param name="currentValue">
        /// The current value
        /// </param>
        /// <param name="model">
        /// The dataset model
        /// </param>
        private void AddVerticalKeyValues(
            IDictionary<string, TableCell> verticalPreviousValues,
            string dimension,
            TableRow outputRow,
            string currentValue,
            IDataSetModel model,
            IDataReader currentRow)
        {
            this._uniqID++;
            Table tb = new Table();
            TableRow _rw = new TableRow();
            Table tb_extra = (this._useSdmxAttr) ? CreateDimensionAttributeTable(dimension, model, currentRow) : null;
            if (tb_extra != null)
            {
                tb_extra.AddAttribute("ID", this._uniqID + "_dim_info_extra_dialog");
                tb_extra.AddClass(HtmlClasses.ExtraInfoTable);

                tb.AddRow(new TableRow(new TableCell(tb_extra)));

                var tb_btn_extra = new TableCell();
                tb_btn_extra.AddClass(HtmlClasses.ExtraInfoWrapper);
                tb_btn_extra.AddAttribute("ID", this._uniqID + "_dim_info");

                _rw.AddCell(tb_btn_extra);
            }

            string text = this.GetLocalizedName(dimension, currentValue);
            var tb_dim = new TableCell();
            tb_dim.AddClass(HtmlClasses.VerticalKeyValue);

            if (dimension == "TIME_PERIOD") tb_dim.AddAttribute("style", "white-space:nowrap");

            tb_dim.SetupDisplayText(currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput);

            _rw.AddCell(tb_dim);
            tb.AddRow(_rw);
            TableCell tb_cell = new TableCell(tb);

            outputRow.AddCell(tb_cell);
            verticalPreviousValues[dimension] = tb_cell;
        }
예제 #14
0
        /// <summary>
        /// Create and setup the titles for horizontal dimensions
        /// </summary>
        /// <param name="model">
        /// The DataSetModel to use
        /// </param>
        /// <param name="horizontalRows">
        /// The horizontal map to add the titles to
        /// </param>
        /// <param name="horizontalOrderedRows">
        /// The list of rows
        /// </param>
        private void CreateHorizontalTitles(
            IDataSetModel model,
            IDictionary<string, TableRow> horizontalRows,
            ICollection<TableRow> horizontalOrderedRows)
        {
            foreach (string dim in model.HorizontalKeys)
            {
                var row = new TableRow();
                row.AddClass(HtmlClasses.HorizontalKeys);

                // First cell is the title, which spawns over all columns used for vertical keys...
                TableCell tableCell = this.CreateTitle(model.AllValidKeys[dim], dim, "hkeytitle");
                tableCell.SetColSpan(Math.Max(1, model.VerticalKeys.Count));
                row.AddCell(tableCell);
                horizontalRows.Add(dim, row);
                horizontalOrderedRows.Add(row);
            }
        }
	protected void loadExpiredRepeatersReport()
	{
		System.Web.UI.ControlCollection pnl = pnlExpiredRepeaters.Controls;
		string json = "";

		if (ViewState["expiredRepeaters"] == null)
		{
			using (var webClient = new System.Net.WebClient())
			{
				string url = String.Format(System.Configuration.ConfigurationManager.AppSettings["webServiceRootUrl"] + "ReportExpiredRepeaters?callsign={0}&password={1}", creds.Username, creds.Password);
				json = webClient.DownloadString(url);
				ViewState["expiredRepeaters"] = json;
			}
		}
		else
		{
			json = ViewState["expiredRepeaters"].ToString();
		}

		dynamic data = JsonConvert.DeserializeObject<dynamic>(json);

		Table table = new Table();
		if ((data.Report != null) && (data.Report.Data != null))
		{
			foreach (dynamic item in data.Report.Data)
			{
				dynamic repeater = item.Repeater;
				
				if ((repeater.City == null) || (((string)repeater.City).Trim() == "")) {
					repeater.City = "[blank]";
				}

				using (TableRow headerRow = new TableRow())
				{
					headerRow.AddCell("Expired");
					headerRow.AddCell("ID");
					headerRow.AddCell("Callsign");
					headerRow.AddCell("Xmit freq");
					headerRow.AddCell("City");
					headerRow.AddCell("Sponsor");
					headerRow.AddCell("Trustee");
					headerRow.AddCell("Contact info");
					headerRow.CssClass = "expiredRepeaterHeader";
					table.Rows.Add(headerRow);
				}

				using (TableRow row = new TableRow())
				{
					row.AddCell((string)repeater.YearsExpired + " years");
					row.AddCell(string.Format("<a target='_blank' title='Update' href='/update/?id={0}'>{0}</a>", (string)repeater.ID));
					row.AddCell(string.Format("<a target='_blank' title='QRZ' href='https://qrz.com/db/{0}'>{0}</a>", (string)repeater.Callsign));
					row.AddCell(string.Format("<a target='_blank' title='RepeaterBook' href='https://repeaterbook.com/repeaters/msResult.php?state_id%5B%5D=05&band=%25&freq={0}&loc=&call=&features=%25&emcomm=%25&coverage=%25&status_id=%25&order=%60freq%60%2C+%60state_abbrev%60+ASC'>{0}</a>", (string)repeater.Output));
					row.AddCell(string.Format("<a target='_blank' href='https://www.google.com/maps/search/?api=1&query={1},{2}'>{0}</a>", (string)repeater.City, (string)repeater.Latitude, (string)repeater.Longitude));
					row.AddCell((string)repeater.Sponsor);
					row.AddCell(string.Format("<a target='_blank' title='QRZ' href='https://qrz.com/db/{0}'>{1}</a>", (string)repeater.Trustee.Callsign, (string)repeater.Trustee.Name));

					string strContact = string.Empty;
					if ((string)repeater.Trustee.Email != string.Empty)
					{
						if (strContact != string.Empty) { strContact += ", "; }
						strContact += "<a href='mailto:" + (string)repeater.Trustee.Email + "'>" + (string)repeater.Trustee.Email + "</a> ";
					}

                    string strPhone = string.Empty;
                    if ((string)repeater.Trustee.CellPhone != string.Empty)
                    {
                        if (strContact != string.Empty) { strContact += ", "; }
                        strPhone = (string)repeater.Trustee.CellPhone;
                        strContact += "<a href='tel:" + strPhone + "'>" + strPhone + "</a> (cell)";
                    }
                    if ((string)repeater.Trustee.HomePhone != string.Empty)
                    {
                        if (strContact != string.Empty) { strContact += ", "; }
                        strPhone = (string)repeater.Trustee.HomePhone;
                        strContact += "<a href='tel:" + strPhone + "'>" + strPhone + "</a> (home)";
                    }
                    if ((string)repeater.Trustee.WorkPhone != string.Empty)
                    {
                        if (strContact != string.Empty) { strContact += ", "; }
                        strPhone = (string)repeater.Trustee.WorkPhone;
                        strContact += "<a href='tel:" + strPhone + "'>" + strPhone + "</a> (work)";
                    }

                    row.AddCell(strContact);
					row.CssClass = "expiredRepeaterData";
					table.Rows.Add(row);
				}

				using (TableRow row = new TableRow())
				{
					string strNotes = "";
					if (repeater.Notes != null)
					{
						strNotes = "<ul>";
						foreach (dynamic obj in repeater.Notes)
						{
							strNotes += string.Format("<li>{0} - {1} ({2}, {3})</li>", obj.Note.Timestamp, obj.Note.Text, obj.Note.User.Name, obj.Note.User.Callsign);
						}
						strNotes += "</ul>";
					}
					else
					{
						strNotes = "<ul><li><em>There are no notes on record for this repeater.</em></li></ul>";
					}
					row.AddCell(strNotes, 8);
					row.CssClass = "expiredRepeaterNotes";
					table.Rows.Add(row);
				}

				using (TableRow row = new TableRow())
				{
					Label label = new Label();
					label.Text = "Note: ";
					TextBox textbox = new TextBox();
					textbox.ID = "txt" + repeater.ID;
					textbox.CssClass = "expiredRepeaterNote";
					Button button = new Button();
					button.CommandArgument = repeater.ID;
					button.CommandName = "saveNote";
					button.Click += Button_Click;
					button.Text = "Save";

					TableCell cell = new TableCell();
					cell.Controls.Add(label);
					cell.Controls.Add(textbox);
					cell.Controls.Add(button);
					cell.ColumnSpan = 8;
					row.Cells.Add(cell);
					row.CssClass = "expiredRepeaterNewNote";
					table.Rows.Add(row);
				}
			}
		}
		pnlExpiredRepeaters.Controls.Add(table);

	}
예제 #16
0
    protected void loadOpenRequestsReport()
    {
        System.Web.UI.ControlCollection pnl = pnlOpenRequests.Controls;
        string json = "";

        if (ViewState["ReportOpenCoordinationRequests"] == null)
        {
            using (var webClient = new System.Net.WebClient())
            {
                string url = String.Format(System.Configuration.ConfigurationManager.AppSettings["webServiceRootUrl"] + "ReportOpenCoordinationRequests?callsign={0}&password={1}", creds.Username, creds.Password);
                json = webClient.DownloadString(url);
                ViewState["ReportOpenCoordinationRequests"] = json;
            }
        }
        else
        {
            json = ViewState["ReportOpenCoordinationRequests"].ToString();
        }

        dynamic data = JsonConvert.DeserializeObject <dynamic>(json);

        Table table = new Table();

        if ((data.Report != null) && (data.Report.Data != null))
        {
            foreach (dynamic item in data.Report.Data)
            {
                dynamic request = item.Request;

                using (TableRow headerRow = new TableRow())
                {
                    headerRow.AddCell("ID", "requestHeader");
                    headerRow.AddCell("Requested on");
                    headerRow.AddCell("Requested by");
                    headerRow.AddCell("Latitude");
                    headerRow.AddCell("Longitude");
                    headerRow.AddCell("Transmit frequency");
                    headerRow.CssClass = "requestHeader";
                    table.Rows.Add(headerRow);
                }

                using (TableRow row = new TableRow())
                {
                    row.AddCell((string)request.ID);
                    row.AddCell((string)request.RequestedDate);
                    row.AddCell((string)request.RequestedBy);
                    row.AddCell((string)request.Latitude);
                    row.AddCell((string)request.Longitude);
                    row.AddCell((string)request.OutputFrequency);
                    row.CssClass = "requestDetails";
                    table.Rows.Add(row);
                }

                using (TableRow row = new TableRow())
                {
                    row.AddCell("Workflows", 6);
                    row.CssClass = "workflowDivider";
                    table.Rows.Add(row);
                }

                using (TableRow headerRow = new TableRow())
                {
                    headerRow.AddCell("&nbsp;");
                    headerRow.AddCell("State");
                    headerRow.AddCell("Status");
                    headerRow.AddCell("Time stamp");
                    headerRow.AddCell("Last reminder");
                    headerRow.AddCell("Note");
                    headerRow.CssClass = "workflowHeader";
                    table.Rows.Add(headerRow);
                }

                foreach (dynamic thing in request.Workflows)
                {
                    dynamic workflow = thing.Workflow;
                    using (TableRow row = new TableRow())
                    {
                        row.AddCell((string)"&nbsp;");
                        row.AddCell((string)workflow.State);
                        row.AddCell((string)workflow.Status);
                        row.AddCell((string)workflow.TimeStamp);
                        row.AddCell((string)workflow.LastReminderSent);
                        row.AddCell((string)workflow.Note);
                        row.CssClass = "workflowDetails";
                        table.Rows.Add(row);
                    }
                }

                using (TableRow row = new TableRow())
                {
                    row.AddCell("Workflows", 6);
                    row.CssClass = "workflowDivider";
                    table.Rows.Add(row);
                }
            }
            pnl.Add(table);
        }
        else
        {
            Label label = new Label();
            label.Text = "There are no coordination requests currently open.";
            pnl.Add(label);
        }
    }
예제 #17
0
        public void TestAddTitle()
        {
            var documentOptions = new DocumentOptions()
            {
                PageSize          = PageSize.A4,
                PageOrientation   = PageOrientation.Portrait,
                DefaultFontFamily = TextFontFamily.TimesNewRoman,
            };
            var builder = new PdfBuilder(documentOptions);

            builder.PageHeader += new PageHeaderEventHandler(this.PageHeader);
            builder.PageFooter += new PageFooterEventHandler(this.PageFooter);

            builder.Open();

            //
            // Fonts
            //
            builder.NewPage();
            builder.NewLine();
            builder.AddTitle("Fonts");
            builder.NewLine();

            builder.AddHeading("Styles");
            builder.AddText("Times New Roman - Normal");
            builder.NewLine();

            builder.AddText("Times New Roman - Bold", TextOptions.Set(FontWeight: TextFontWeight.Bold));

            builder.NewLine();

            builder.AddText("Times New Roman - Italic", TextOptions.Set(FontStyle: TextFontStyle.Italic));
            builder.NewLine();

            builder.AddText("Times New Roman - Italic Bold", TextOptions.Set(FontStyle: TextFontStyle.Italic, FontWeight: TextFontWeight.Bold));
            builder.NewLine();

            builder.AddText("Arial - Normal", TextOptions.Set(FontFamily: TextFontFamily.Arial));
            builder.NewLine();

            builder.AddText("Arial - Bold", TextOptions.Set(FontFamily: TextFontFamily.Arial, FontWeight: TextFontWeight.Bold));
            builder.NewLine();

            builder.AddText("Arial - Italic", TextOptions.Set(FontFamily: TextFontFamily.Arial, FontStyle: TextFontStyle.Italic));
            builder.NewLine();

            builder.AddText("Arial - Italic Bold", TextOptions.Set(FontFamily: TextFontFamily.Arial, FontStyle: TextFontStyle.Italic, FontWeight: TextFontWeight.Bold));
            builder.NewLine();
            builder.NewLine();

            builder.AddHeading("Colors");
            builder.AddText("Red", TextOptions.Set(FontColor: Color.Red));
            builder.NewLine();
            builder.AddText("Green", TextOptions.Set(FontColor: Color.Green));
            builder.NewLine();
            builder.AddText("Blue", TextOptions.Set(FontColor: Color.Blue));
            builder.NewLine();


            //
            // Paragraphs
            //

            builder.NewPage();
            builder.NewLine();
            builder.AddTitle("Paragraphs");
            builder.NewLine();

            builder.AddHeading("Left Aligned");
            builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
            builder.NewLine();

            builder.AddHeading("Center Aligned");
            builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", ParagraphOptions.Set(TextAlignment: TextAlignment.Center));
            builder.NewLine();

            builder.AddHeading("Right Aligned");
            builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", ParagraphOptions.Set(TextAlignment: TextAlignment.Right));
            builder.NewLine();

            builder.AddHeading("Justified Aligned");
            builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", ParagraphOptions.Set(TextAlignment: TextAlignment.Justify));
            builder.NewLine();


            //
            // Images
            //

            builder.NewPage();
            builder.NewLine();
            builder.AddTitle("Images");
            builder.NewLine();

            string imagepath = @"Sunset.jpg";

            builder.AddImage(imagepath, 50);
            builder.NewLine();

            builder.AddImage(imagepath, 100);
            builder.NewLine();

            builder.AddImage(imagepath, 150);
            builder.NewLine();


            //
            // Tables
            //

            builder.NewPage();
            builder.NewLine();
            builder.AddTitle("Tables");
            builder.NewLine();

            var tableOptions = TableOptions.Set(
                DefaultFontFamily: TextFontFamily.TimesNewRoman,
                BorderHeaderWidth: 1.0,
                BorderTopWidth: 0.0,
                BorderBottomWidth: 1.0,
                BorderHorizontalWidth: 0.8,
                BorderVerticalWidth: 0.6,
                BorderVerticalColor: Color.DarkGray,
                ColumnWidths: new List <double>(new double[] { 1.0, 2.0, 1.0 })
                );

            var table = new Table(tableOptions);

            var headerCellOptions = new TableCellOptions()
            {
                FontOptions     = table.Options.HeaderFontOptions,
                TextAlignment   = TextAlignment.Center,
                BackgroundColor = Color.LightGray
            };

            // change font family from the default
            headerCellOptions.FontOptions.FontFamily = TextFontFamily.Arial;

            var headerRowOptions = TableRowOptions.Set(TableCellOptions: headerCellOptions);

            var headers = new TableRow(headerRowOptions);

            headers.AddCell("Header 1");
            headers.AddCell("Header 2");
            headers.AddCell("Header 3");
            table.AddHeaders(headers);


            // default options for a table cell
            var defaultTableCellOptions = new TableCellOptions()
            {
                FontOptions = table.Options.CellFontOptions,
            };

            // change the font color
            defaultTableCellOptions.FontOptions.FontColor = Color.DarkGray;

            // specific cell options
            var descriptionTableCellOptions = TableCellOptions.Set(FontColor: Color.Red, FontFamily: table.Options.DefaultFontFamily);
            var amountTableCellOptions      = TableCellOptions.Set(TextAlignment: TextAlignment.Right, BackgroundColor: Color.LightGreen, FontFamily: TextFontFamily.Arial);

            // default options for a table row
            var defaultTableRowOptions = TableRowOptions.Set(TableCellOptions: defaultTableCellOptions);

            var row1 = new TableRow(defaultTableRowOptions);

            row1.AddCell("Row 1");
            row1.AddCell("Item 1", descriptionTableCellOptions);
            row1.AddCell("123.00", amountTableCellOptions);
            table.AddRow(row1);

            var row2 = new TableRow(defaultTableRowOptions);

            row2.AddCell("Row 2");
            row2.AddCell("Item 2", descriptionTableCellOptions);
            row2.AddCell("123.00", amountTableCellOptions);
            table.AddRow(row2);

            var row3 = new TableRow(defaultTableRowOptions);

            row2.AddCell("Row 3");
            row2.AddCell("Item 3", descriptionTableCellOptions);
            row2.AddCell("123.00", amountTableCellOptions);
            table.AddRow(row2);

            builder.AddTable(table);



            //
            // Lines
            //

            builder.NewPage();
            builder.NewLine();
            builder.AddTitle("Lines");
            builder.NewLine();

            var lineOptions = new LineOptions()
            {
                LineColor = Color.Blue,
                LineWidth = 1.0
            };

            builder.AddLine(80, LineOptions.Set(LineColor: Color.Blue));
            builder.NewLine();

            builder.AddLine(140, LineOptions.Set(LineColor: Color.Green));
            builder.NewLine();

            builder.AddLine(190, LineOptions.Set(LineColor: Color.Red));


            // save file
            var    guid     = System.Guid.NewGuid();
            string filepath = String.Format("TestPdfBuilder_{0}.pdf", guid.ToString("N"));

            using (var fileStream = new FileStream(filepath, FileMode.Create, FileAccess.Write))
            {
                byte[] data = builder.GetBytes();
                fileStream.Write(data, 0, data.Length);
            }

            builder.Close();

            Assert.IsTrue(1 == 1);
        }
예제 #18
0
    protected void loadExpiredRepeatersReport()
    {
        System.Web.UI.ControlCollection pnl = pnlExpiredRepeaters.Controls;
        string json = "";

        if (ViewState["expiredRepeaters"] == null)
        {
            using (var webClient = new System.Net.WebClient())
            {
                string url = String.Format(System.Configuration.ConfigurationManager.AppSettings["webServiceRootUrl"] + "ReportNonstandardRepeaters?callsign={0}&password={1}", creds.Username, creds.Password);
                json = webClient.DownloadString(url);
                ViewState["expiredRepeaters"] = json;
            }
        }
        else
        {
            json = ViewState["expiredRepeaters"].ToString();
        }

        dynamic data = JsonConvert.DeserializeObject <dynamic>(json);

        lblTitle.Text  = data.Report.Title;
        lblTitle2.Text = data.Report.Title;

        Table table = new Table();

        if (data.Report != null)
        {
            foreach (dynamic item in data.Report.Data)
            {
                dynamic repeater = item.Repeater;

                using (TableRow headerRow = new TableRow())
                {
                    headerRow.AddCell("ID");
                    headerRow.AddCell("Callsign");
                    headerRow.AddCell("Xmit freq");
                    headerRow.AddCell("Rcv freq");
                    headerRow.AddCell("City");
                    headerRow.AddCell("Sponsor");
                    headerRow.AddCell("Trustee");
                    headerRow.AddCell("Contact info");
                    headerRow.CssClass = "expiredRepeaterHeader";
                    table.Rows.Add(headerRow);
                }

                using (TableRow row = new TableRow())
                {
                    row.AddCell(string.Format("<a target='_blank' href='/update/?id={0}'>{0}</a>", (string)repeater.ID));
                    row.AddCell(string.Format("<a target='_blank' href='https://qrz.com/db/{0}'>{0}</a>", (string)repeater.Callsign));
                    row.AddCell((string)repeater.Output);
                    row.AddCell((string)repeater.Input);
                    row.AddCell((string)repeater.City);
                    row.AddCell((string)repeater.Sponsor);
                    row.AddCell(string.Format("<a target='_blank' href='https://qrz.com/db/{0}'>{1}</a>", (string)repeater.Trustee.Callsign, (string)repeater.Trustee.Name));

                    string strContact = string.Empty;
                    if ((string)repeater.Trustee.Email != string.Empty)
                    {
                        if (strContact != string.Empty)
                        {
                            strContact += ", ";
                        }
                        strContact += "<a href='mailto:" + (string)repeater.Trustee.Email + "'>" + (string)repeater.Trustee.Email + "</a> ";
                    }

                    string strPhone = string.Empty;
                    if ((string)repeater.Trustee.CellPhone != string.Empty)
                    {
                        if (strContact != string.Empty)
                        {
                            strContact += ", ";
                        }
                        strPhone    = (string)repeater.Trustee.CellPhone;
                        strContact += "<a href='tel:" + strPhone + "'>" + strPhone + "</a> (cell)";
                    }
                    if ((string)repeater.Trustee.HomePhone != string.Empty)
                    {
                        if (strContact != string.Empty)
                        {
                            strContact += ", ";
                        }
                        strPhone    = (string)repeater.Trustee.HomePhone;
                        strContact += "<a href='tel:" + strPhone + "'>" + strPhone + "</a> (home)";
                    }
                    if ((string)repeater.Trustee.WorkPhone != string.Empty)
                    {
                        if (strContact != string.Empty)
                        {
                            strContact += ", ";
                        }
                        strPhone    = (string)repeater.Trustee.WorkPhone;
                        strContact += "<a href='tel:" + strPhone + "'>" + strPhone + "</a> (work)";
                    }

                    row.AddCell(strContact);
                    row.CssClass = "expiredRepeaterData";
                    table.Rows.Add(row);
                }

                using (TableRow row = new TableRow())
                {
                    string strNotes = "";
                    if (repeater.Notes != null)
                    {
                        strNotes = "<ul>";
                        foreach (dynamic obj in repeater.Notes)
                        {
                            string note = ((string)obj.Note.Text).Replace("•", "<br>&bull;");
                            strNotes += string.Format("<li>{0} - {1} ({2}, {3})</li>", obj.Note.Timestamp, note, obj.Note.User.Name, obj.Note.User.Callsign);
                        }
                        strNotes += "</ul>";
                    }
                    else
                    {
                        strNotes = "<ul><li><em>There are no notes on record for this repeater.</em></li></ul>";
                    }
                    row.AddCell(strNotes, 8);
                    row.CssClass = "expiredRepeaterNotes";
                    table.Rows.Add(row);
                }

                using (TableRow row = new TableRow())
                {
                    Label label = new Label();
                    label.Text = "Note: ";
                    TextBox textbox = new TextBox();
                    textbox.ID       = "txt" + repeater.ID;
                    textbox.CssClass = "expiredRepeaterNote";
                    Button button = new Button();
                    button.CommandArgument = repeater.ID;
                    button.CommandName     = "saveNote";
                    button.Click          += Button_Click;
                    button.Text            = "Save";

                    TableCell cell = new TableCell();
                    cell.Controls.Add(label);
                    cell.Controls.Add(textbox);
                    cell.Controls.Add(button);
                    cell.ColumnSpan = 8;
                    row.Cells.Add(cell);
                    row.CssClass = "expiredRepeaterNewNote";
                    table.Rows.Add(row);
                }
            }
        }
        pnlExpiredRepeaters.Controls.Add(table);
    }
예제 #19
0
    protected void loadMostWanted()
    {
        //lblMostWanted.Text = "<h3>10 most wanted</h3>";
        System.Web.UI.ControlCollection pnl = pnlMostWanted.Controls;
        string json = "";

        using (var webClient = new System.Net.WebClient())
        {
            string url = String.Format("{0}{1}", System.Configuration.ConfigurationManager.AppSettings["webServiceRootUrl"], "ReportExpiredRepeaters");
            json = webClient.DownloadString(url);
            ViewState["expiredRepeaters"] = json;
        }

        dynamic data = JsonConvert.DeserializeObject <dynamic>(json);

        if (data.Report != null)
        {
            Label lbl = new Label();
            lbl.Text = string.Format("<h3>{0}</h3><p>These repeaters have expired their coordination. If you know anything that may lead to the <del>arrest and conviction</del> updating of this record, please contact us or the repeater owner.", data.Report.Title);
            pnl.Add(lbl);

            Table table = new Table();
            using (TableRow headerRow = new TableRow())
            {
                headerRow.AddCell("Expired");
                headerRow.AddCell("Repeater");
                headerRow.AddCell("City");
                headerRow.AddCell("Sponsor");
                headerRow.AddCell("Trustee");
                headerRow.CssClass = "expiredRepeaterHeader";
                table.Rows.Add(headerRow);
            }

            if (data.Report.Data != null)
            {
                foreach (dynamic item in data.Report.Data)
                {
                    dynamic repeater = item.Repeater;

                    using (TableRow row = new TableRow())
                    {
                        row.AddCell((string)repeater.YearsExpired + " yrs");
                        row.AddCell(string.Format("<a target='_blank' title='Details' href='/repeaters/details/?id={0}'>{1}<br>{2}</a>", (string)repeater.ID, (string)repeater.Output, (string)repeater.Callsign));
                        row.AddCell((string)repeater.City);
                        row.AddCell((string)repeater.Sponsor);
                        row.AddCell(string.Format("<a target='_blank' title='QRZ' href='https://qrz.com/db/{0}'>{1}</a>", (string)repeater.Trustee.Callsign, (string)repeater.Trustee.Name));
                        row.CssClass = "expiredRepeaterData";
                        table.Rows.Add(row);
                    }
                }
            }
            else
            {
                using (TableRow row = new TableRow())
                {
                    row.AddCell("None! We're all current! Yay!", 5);
                    row.CssClass = "expiredRepeaterData";
                    table.Rows.Add(row);
                }
            }
            pnl.Add(table);
        }
    }
예제 #20
0
 /// <summary>
 /// Add horrizontal key values to the specified output Row
 /// </summary>
 /// <param name="horizontalPreviousValues">
 /// A map of {key,  previous value of key} 
 /// </param>
 /// <param name="dimension">
 /// The current key
 /// </param>
 /// <param name="outputRow">
 /// The row to add the key values
 /// </param>
 /// <param name="currentValue">
 /// The current value
 /// </param>
 /// <param name="model">
 /// The dataset model
 /// </param>
 private void AddHorrizontalKeyValues(
     IDictionary<string, TableCell> horizontalPreviousValues, 
     string dimension, 
     TableRow outputRow, 
     string currentValue, 
     IDataSetModel model)
 {
     TableCell oldValue;
     if (horizontalPreviousValues.TryGetValue(dimension, out oldValue) && oldValue != null
         && string.Equals(currentValue, oldValue.SdmxValue))
     {
         oldValue.ColumnSpan++;
     }
     else
     {
         var tableCell = new TableCell();
         string text = this.GetLocalizedName(dimension, currentValue);
         tableCell.SetupDisplayText(
             currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput);
         tableCell.AddClass(HtmlClasses.HorizontalKeyValue);
         outputRow.AddCell(tableCell);
         horizontalPreviousValues[dimension] = tableCell;
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create word document
            Document document = new Document();

            //Create a new section
            Section section = document.AddSection();

            //Create a table width default borders
            Table table = section.AddTable(true);
            //Set table with to 100%
            PreferredWidth width = new PreferredWidth(WidthType.Percentage, 100);

            table.PreferredWidth = width;

            //Add a new row
            TableRow row = table.AddRow();

            //Set the row as a table header
            row.IsHeader = true;
            //Set the backcolor of row
            row.RowFormat.BackColor = Color.LightGray;
            //Add a new cell for row
            TableCell cell = row.AddCell();

            cell.SetCellWidth(100, CellWidthType.Percentage);
            //Add a paragraph for cell to put some data
            Paragraph parapraph = cell.AddParagraph();

            //Add text
            parapraph.AppendText("Row Header 1");
            //Set paragraph horizontal center alignment
            parapraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

            row                     = table.AddRow(false, 1);
            row.IsHeader            = true;
            row.RowFormat.BackColor = Color.Ivory;
            //Set row height
            row.Height = 30;
            cell       = row.Cells[0];
            cell.SetCellWidth(100, CellWidthType.Percentage);
            //Set cell vertical middle alignment
            cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
            //Add a paragraph for cell to put some data
            parapraph = cell.AddParagraph();
            //Add text
            parapraph.AppendText("Row Header 2");
            parapraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

            //Add many common rows
            for (int i = 0; i < 70; i++)
            {
                row  = table.AddRow(false, 2);
                cell = row.Cells[0];
                //Set cell width to 50% of table width
                cell.SetCellWidth(50, CellWidthType.Percentage);
                cell.AddParagraph().AppendText("Column 1 Text");
                cell = row.Cells[1];
                cell.SetCellWidth(50, CellWidthType.Percentage);
                cell.AddParagraph().AppendText("Column 2 Text");
            }
            //Set cell backcolor
            for (int j = 1; j < table.Rows.Count; j++)
            {
                if (j % 2 == 0)
                {
                    TableRow row2 = table.Rows[j];
                    for (int f = 0; f < row2.Cells.Count; f++)
                    {
                        row2.Cells[f].CellFormat.BackColor = Color.LightBlue;
                    }
                }
            }

            String result = "RepeatRowOnEachPage_out.docx";

            //Save file.
            document.SaveToFile(result, FileFormat.Docx);

            //Launching the Word file.
            WordDocViewer(result);
        }
예제 #22
0
        /// <summary>
        /// Parse a data row and populate the <see cref="RendererState.CurrentTableRow"/> with the X, Y axis key values and the data
        /// </summary>
        /// <param name="state">
        /// The current state
        /// </param>
        protected virtual void ParseDataRow(RendererState state, object vc = null, object vt = null)
        {
            #region check if something has changed
            state.HorizontalCurrentKeySet = MakeKey(state.Model.HorizontalKeys, state.InputRow);
            if (!string.Equals(state.HorizontalCurrentKeySet, state.HorizontalOldKeySet))
            {
                state.CurrentHorizontalKeySetColumn++;
                state.HorizontalOldKeySet = state.HorizontalCurrentKeySet;

                foreach (TableRow row in state.VerticalKeySetIndex.Values)
                {

                    TableCell emptyMeasure = new TableCell("-");
                    emptyMeasure.AddClass(HtmlClasses.NotMeasure);
                    row.AddElement(emptyMeasure);
                }

                foreach (string dim in state.Model.HorizontalKeys)
                {
                    TableRow horizontalKeyRow = state.HorizontalKeyRows[dim];
                    var currentValue = state.InputRow[dim] as string;

                    this.AddHorrizontalKeyValues(
                        state.VerticalPreviousValuesMap,
                        dim,
                        horizontalKeyRow,
                        currentValue,
                        state.Model,
                        state.InputRow);

                }
            }
            #endregion

            TableRow currentRow;

            state.VerticalCurrentKeySet = MakeKey(state.Model.VerticalKeys, state.InputRow);
            if (!state.VerticalKeySetIndex.TryGetValue(state.VerticalCurrentKeySet, out currentRow))
            {
                state.CurrentTableRow = new TableRow();
                if (state.Model.VerticalKeys.Count == 0 && state.Model.HorizontalKeys.Count > 0)
                {
                    TableCell emptyMeasure = new TableCell("-");
                    emptyMeasure.AddClass(HtmlClasses.NotMeasure);
                    state.CurrentTableRow.AddElement(emptyMeasure);
                }

                state.VerticalKeySetIndex.Add(state.VerticalCurrentKeySet, state.CurrentTableRow);
                state.VerticalOrderedRows.Add(state.CurrentTableRow);

                foreach (string dim in state.Model.VerticalKeys)
                {
                    var currentValue = state.InputRow[dim] as string;
                    this.AddVerticalKeyValues(
                        state.HorizontalPreviousValuesMap,
                        dim,
                        state.CurrentTableRow,
                        currentValue,
                        state.Model,
                        state.InputRow);
                }

                int currentVerticalKeyValueCount = state.CurrentTableRow.Children.Count;
                state.VerticalKeyValueCount.Add(state.VerticalCurrentKeySet, currentVerticalKeyValueCount);

                state.CurrentVerticalKeyValueCount = currentVerticalKeyValueCount;

                for (int i = 0; i < state.CurrentHorizontalKeySetColumn; i++)
                {
                    TableCell emptyMeasure = new TableCell("-");
                    emptyMeasure.AddClass(HtmlClasses.NotMeasure);
                    state.CurrentTableRow.AddElement(emptyMeasure);
                }
            }
            else
            {
                state.CurrentTableRow = currentRow;
                state.CurrentVerticalKeyValueCount = state.VerticalKeyValueCount[state.VerticalCurrentKeySet];
            }

            //var time = state.InputRow[state.Model.KeyFamily.TimeDimension.Id] as string;
            NumberStyles style;
            style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowLeadingSign;

            var val = state.InputRow[state.Model.KeyFamily.PrimaryMeasure.Id] as string;
            if (string.IsNullOrEmpty(val)
                || val == "NaN")
            {
                val = string.Empty;
            }
            else {
                decimal decVal = 0;
                Int32 intVal = 0;
                if (Int32.TryParse(val.ToString(), out intVal))
                {
                    val = intVal.ToString();
                }
                else if (decimal.TryParse(val.ToString(), style, cFrom, out decVal))
                {
                    val = decVal.ToString("F1", cTo);
                }
            }

            TableCell data_cell;
            if (string.IsNullOrEmpty(val))
            {
                data_cell = new TableCell("-");
                data_cell.AddClass(HtmlClasses.NotMeasure);

            }else{

                this._uniqID++;
                Table tb = new Table();
                TableRow _rw = new TableRow();
                // Add table info extra at level observation
                Table tb_extra =
                    (this._useSdmxAttr) ?
                    (!string.IsNullOrEmpty(val)) ?
                        CreateObservationAttribute(state.Model, state.InputRow) : null : null;
                if (tb_extra != null)
                {
                    tb_extra.AddAttribute("ID", this._uniqID + "_info_extra_dialog");
                    tb_extra.AddClass(HtmlClasses.ExtraInfoTable);

                    tb.AddRow(new TableRow(new TableCell(tb_extra)));

                    var tb_btn_extra = new TableCell();
                    tb_btn_extra.AddClass(HtmlClasses.ExtraInfoWrapper);
                    tb_btn_extra.AddAttribute("ID", this._uniqID + "_info");

                    _rw.AddCell(tb_btn_extra);
                }
                /*
                decimal decVal_vc = 0;
                if (vc != null && decimal.TryParse(vc.ToString(), NumberStyles.AllowDecimalPoint, cFrom, out decVal_vc))
                {
                    vc = decVal_vc.ToString("F1", cTo);
                }
                decimal decVal_vt = 0;
                if (vt != null && decimal.TryParse(vt.ToString(), NumberStyles.AllowDecimalPoint, cFrom, out decVal_vt))
                {
                    vt = decVal_vt.ToString("F1", cTo);
                }
                */
                TableCell measure = new TableCell((string.IsNullOrEmpty(val)) ? "-" : val);
                measure.AddClass((string.IsNullOrEmpty(val)) ? HtmlClasses.NotMeasure : HtmlClasses.Measure);
                measure.AddAttribute("data-v", (string.IsNullOrEmpty(val)) ? "-" : val);
                measure.AddAttribute("data-vc", (vc == null) ? "?" : vc.ToString());
                measure.AddAttribute("data-vt", (vt == null) ? "?" : vt.ToString());

                _rw.AddCell(measure);

                tb.AddRow(_rw);

                data_cell = new TableCell(tb);
                data_cell.AddClass(HtmlClasses.ExtraInfoTableValue);

            }

            int column = state.CurrentHorizontalKeySetColumn + state.CurrentVerticalKeyValueCount;
            state.CurrentTableRow.AddAt(data_cell, column);
        }
		public override bool LoadTableData(TableDescription TableDataContent)
			{
			TableDataContent.NameID = "Abgegeben je Kommission" + NameID;
			TableDataContent.HeadLine = String.Format("Abgegebene Stimmen bei der Kommission {0} ", NameID);

			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Komm." });
			foreach (String WahlKurzName in Years)
				{
				TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = WahlKurzName });

				}
			foreach (AbgegebenKommissionsSummen RowEntry in ItemsSource)
				{
				MBRWahl.TableRow NewRow = new TableRow();
				NewRow.FirstCellIsRowHeader = true;
				NewRow.AddCell (new TableCell (){Text = RowEntry.AktuelleKommissionsID});

				foreach (AbgegebenKommissionsSummen SummenPerWahl in RowEntry.AbgegebenJeVergleichsWahl)
					{
					MBRWahl.TableDescription PopupTable = null;
					if (SummenPerWahl.AbgegebenJeStiege.Count > 0)		// Add third dimension popup informations
						{
						PopupTable = new TableDescription ();
						PopupTable.HeadLine = "Woher stammen die Stimmen";
						PopupTable.NameID = "VotesComeFrom";
						foreach (AbgegebenKommissionsSummen ComesFrom in SummenPerWahl.AbgegebenJeStiege)
							{
							MBRWahl.TableRow NewPopupRow = new TableRow ();
							NewPopupRow.AddCell (new TableCell () {Text = Convert.ToString (ComesFrom.Abgegeben)});

							NewPopupRow.AddCell(new TableCell() { Text = ComesFrom.BlockName + " " + ComesFrom.StiegenNummer });
							PopupTable.Rows.AddRow(NewPopupRow);
							}
						}
					NewRow.AddCell(new TableCell() { Text = Convert.ToString(SummenPerWahl.Abgegeben),
					ThirdLevelAdditionalInfos = PopupTable});
					}
				TableDataContent.Rows.AddRow(NewRow);
				}
			return true;
			}
예제 #24
0
        /// <summary>
        /// Add horrizontal key values to the specified output Row
        /// </summary>
        /// <param name="horizontalPreviousValues">
        /// A map of {key,  previous value of key} 
        /// </param>
        /// <param name="dimension">
        /// The current key
        /// </param>
        /// <param name="outputRow">
        /// The row to add the key values
        /// </param>
        /// <param name="currentValue">
        /// The current value
        /// </param>
        /// <param name="model">
        /// The dataset model
        /// </param>
        private void AddHorrizontalKeyValues(
            IDictionary<string, TableCell> horizontalPreviousValues,
            string dimension,
            TableRow outputRow,
            string currentValue,
            IDataSetModel model,
            IDataReader currentRow)
        {
            TableCell oldCell;
            horizontalPreviousValues.TryGetValue(dimension, out oldCell);

            string oldValue = string.Empty;

            if (oldCell != null &&
                oldCell.Children.Count > 0 &&
                oldCell.Children[0].Children.Count > 0 &&
                oldCell.Children[0].Children[0].Children.Count > 1)
                oldValue = oldCell.Children[0].Children[0].Children[0].SdmxValue;
            else if (oldCell != null)
                oldValue = oldCell.SdmxValue;

            if (oldCell != null && string.Equals(currentValue, oldValue))
            {
                oldCell.ColumnSpan++;
            }
            else
            {

                this._uniqID++;
                Table tb = new Table();
                TableRow _rw = new TableRow();
                Table tb_extra = (this._useSdmxAttr) ? CreateDimensionAttributeTable(dimension, model, currentRow) : null;
                if (tb_extra != null)
                {
                    tb_extra.AddAttribute("ID", this._uniqID + "_dim_info_extra_dialog");
                    tb_extra.AddClass(HtmlClasses.ExtraInfoTable);

                    tb.AddRow(new TableRow(new TableCell(tb_extra)));

                    var tb_btn_extra = new TableCell();
                    tb_btn_extra.AddClass(HtmlClasses.ExtraInfoWrapper);
                    tb_btn_extra.AddAttribute("ID", this._uniqID + "_dim_info");

                    _rw.AddCell(tb_btn_extra);
                }

                string text = this.GetLocalizedName(dimension, currentValue);
                var tb_dim = new TableCell();
                tb_dim.AddClass(HtmlClasses.HorizontalKeyValue);
                tb_dim.SetupDisplayText(currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput);

                if (dimension == "TIME_PERIOD") tb_dim.AddAttribute("style", "white-space:nowrap");

                _rw.AddCell(tb_dim);

                tb.AddRow(_rw);
                TableCell tb_cell = new TableCell(tb);
                tb_cell.SdmxValue = currentValue;
                outputRow.AddCell(tb_cell);
                horizontalPreviousValues[dimension] = tb_cell;

            }
        }
		public override bool LoadTableData(TableDescription TableDataContent)
			{
			TableDataContent.NameID = "Abgegeben je Stiege" + NameID;
			TableDataContent.HeadLine = String.Format("Abgegebene Stimmen aus der Stiege {0} ", NameID);

			TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = "Block" });
			foreach (String WahlKurzName in Years)
				{
				TableDataContent.ColumnHeader.AddCell(new TableCell() { Text = WahlKurzName });

				}
			foreach (AbgegebenStiegenSummen RowEntry in ItemsSource)
				{
				TableRow NewRow = new TableRow();
				NewRow.FirstCellIsRowHeader = true;
				NewRow.AddCell(new TableCell() { Text = RowEntry.Block + " " + RowEntry.StiegenNummer});
				foreach (AbgegebenStiegenSummen SummenPerWahl in RowEntry.AbgegebenJeVergleichsWahl)
					{
					NewRow.AddCell(new TableCell() { Text = Convert.ToString (SummenPerWahl.Abgegeben)});
					}
				TableDataContent.Rows.AddRow(NewRow);
				}
			return true;
			}
예제 #26
0
        //导出按钮点击事件
        private void button2_Click(object sender, EventArgs e)
        {
            int num = 0;

            if (textBox2.Text != "")
            {
                num = Convert.ToInt32(textBox2.Text);
            }

            //创建Word文档
            Document doc = new Document();
            //添加section
            Section section = doc.AddSection();

            //添加表格
            Table table = section.AddTable(true);

            //添加第1行
            TableRow  row1  = table.AddRow();
            TableCell cell1 = row1.AddCell();

            cell1.AddParagraph().AppendText("题 号");
            cell1.CellFormat.BackColor = Color.Gold;
            TableCell cell2 = row1.AddCell();

            cell2.AddParagraph().AppendText("题 目");

            TableCell cell3 = row1.AddCell();

            cell3.AddParagraph().AppendText("题 号");
            cell3.CellFormat.BackColor = Color.Gold;
            TableCell cell4 = row1.AddCell();

            cell4.AddParagraph().AppendText("题 目");

            TableCell cell5 = row1.AddCell();

            cell5.AddParagraph().AppendText("题 号");
            cell5.CellFormat.BackColor = Color.Gold;
            TableCell cell6 = row1.AddCell();

            cell6.AddParagraph().AppendText("题 目");

            TableCell cell7 = row1.AddCell();

            cell7.AddParagraph().AppendText("题 号");
            cell7.CellFormat.BackColor = Color.Gold;
            TableCell cell8 = row1.AddCell();

            cell8.AddParagraph().AppendText("题 目");

            int j = 0;

            for (int i = 0; i < num / 4 + 1; i++)
            {
                TableRow row = table.AddRow();
                j++;
                if (j < num + 1)
                {
                    table.Rows[i + 1].Cells[0].AddParagraph().AppendText(j.ToString());
                    table.Rows[i + 1].Cells[0].CellFormat.BackColor = Color.Gold;
                    table.Rows[i + 1].Cells[1].AddParagraph().AppendText(shizi[j - 1]);
                }
                j++;
                if (j < num + 1)
                {
                    table.Rows[i + 1].Cells[2].AddParagraph().AppendText(j.ToString());
                    table.Rows[i + 1].Cells[2].CellFormat.BackColor = Color.Gold;
                    table.Rows[i + 1].Cells[3].AddParagraph().AppendText(shizi[j - 1]);
                }

                j++;
                if (j < num + 1)
                {
                    table.Rows[i + 1].Cells[4].AddParagraph().AppendText(j.ToString());
                    table.Rows[i + 1].Cells[4].CellFormat.BackColor = Color.Gold;
                    table.Rows[i + 1].Cells[5].AddParagraph().AppendText(shizi[j - 1]);
                }
                j++;
                if (j < num + 1)
                {
                    table.Rows[i + 1].Cells[6].AddParagraph().AppendText(j.ToString());
                    table.Rows[i + 1].Cells[6].CellFormat.BackColor = Color.Gold;
                    table.Rows[i + 1].Cells[7].AddParagraph().AppendText(shizi[j - 1]);
                }
            }
            //保存文档
            table.AutoFit(AutoFitBehaviorType.FixedColumnWidths);
            doc.SaveToFile("Table.docx");
            MessageBox.Show("导出成功!");
        }