/// <summary> /// Method for create/add data into a table row with properties /// </summary> /// <param name=word_rows">Destination rows that we will write and add to Word</param> /// <param name=data">A table contains input data taken from databse</param /// <returns> The TableRow instance that has applied properties and values</returns> protected void AddDataToTable(List <TableRow> table_row_list, DataTable data) { int column_count = 0; foreach (TableRow table_row in table_row_list) { int cell_count = table_row.Descendants <TableCell>().Count(); for (int i = 0; i < cell_count; i++) { bool is_data_exists = (column_count < data.Columns.Count && data.Rows[0][column_count].ToString() != null); string append_text = (is_data_exists ? data.Rows[0][column_count].ToString() : StaticValues.no_data_found_str); // Check for image urls if (Helper_WordPicture.IsUrl(append_text) && Helper_WordPicture.IsImageUrl(append_text)) { image_urls.Add(append_text); column_count++; continue; } // Get data from 1st row only if (table_row.Descendants <TableCell>().ElementAt(i).InnerText.ToLower() == StaticValues.value_placeholder_name) { Run run = new Run(new Text(append_text)); ChangeCellData(table_row, i, run); column_count++; } } } AddImagesInTable(); }
/// <summary> /// Add image to table (if some links is founds) /// </summary> protected void AddImagesInTable() { List <SdtElement> image_ccs = content_control.Descendants <SdtElement>().Where(s => s.Descendants <SdtAlias>().FirstOrDefault().Val.ToString().ToLower() == StaticValues.image_cc_name).ToList(); if (image_ccs.Count == 0 || image_urls.Count == 0) { return; } int count = 0; foreach (SdtElement image_cc in image_ccs) { if (count < image_urls.Count) { Helper_WordPicture pic_helper = new Helper_WordPicture(image_cc, image_urls[count]); pic_helper.AddPictureFromUri(); } } }