示例#1
0
        public static void createLegalSAndEDueOtherReportTable(Application app, System.Data.DataTable listData, string bookmarkNameAttachment, string bookmarkNameDescription, string currFontFamily, float currFontSize)
        {
            object missing       = System.Reflection.Missing.Value;
            Table  tblAttachment = IIFCommon.createTable(app, bookmarkNameAttachment, 1, false);

            tblAttachment.Columns[1].Width = 250;
            tblAttachment.Borders.Enable   = 0;
            int rowCounter = 0;

            foreach (DataRow item in listData.Rows)
            {
                tblAttachment.Rows.Add(ref missing);
                rowCounter++;
                string valueAttachmentName = IIFCommon.readValueHTMLString(item[0].ToString(), "name");
                if (valueAttachmentName.ToLower() == "scnull")
                {
                    valueAttachmentName = "-";
                }
                tblAttachment.Cell(rowCounter, 1).Range.Text = valueAttachmentName;
                tblAttachment.Cell(rowCounter, 1).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
                tblAttachment.Cell(rowCounter, 1).Range.ParagraphFormat.Alignment      = WdParagraphAlignment.wdAlignParagraphLeft;
            }
            tblAttachment.Rows[rowCounter + 1].Delete();

            Table tblDescription = IIFCommon.createTable(app, bookmarkNameDescription, 1, false);

            tblDescription.Columns[1].Width = 250;
            tblDescription.Borders.Enable   = 0;
            rowCounter = 0;
            foreach (DataRow item in listData.Rows)
            {
                tblDescription.Rows.Add(ref missing);
                rowCounter++;
                tblDescription.Cell(rowCounter, 1).Range.Text = item[1].ToString();
                tblDescription.Cell(rowCounter, 1).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
                tblDescription.Cell(rowCounter, 1).Range.ParagraphFormat.Alignment      = WdParagraphAlignment.wdAlignParagraphLeft;
                tblDescription.Cell(rowCounter, 1).Range.Font.Name = currFontFamily;
                tblDescription.Cell(rowCounter, 1).Range.Font.Size = currFontSize;
            }
            tblDescription.Rows[rowCounter + 1].Delete();
        }
示例#2
0
        public static void createPreviousApproval(Application app, System.Data.DataTable listData, string bookmarkName, List <CMData> dataResult, string currFontFamily, float currFontSize)
        {
            Table tblPreviousApproval = IIFCommon.createTable(app, bookmarkName, 5, true);

            tblPreviousApproval.Borders.Enable = 1;

            //header
            tblPreviousApproval.Cell(1, 1).Range.Text = "Type Document";
            tblPreviousApproval.Cell(1, 2).Range.Text = "No. Document";
            tblPreviousApproval.Cell(1, 3).Range.Text = "Approval";
            tblPreviousApproval.Cell(1, 4).Range.Text = "Approval Date";
            tblPreviousApproval.Cell(1, 5).Range.Text = "Purpose";

            int    rowCounter = 1;
            object missing    = System.Reflection.Missing.Value;

            string cmNumber = IIFCommon.generateCMNumber(
                dataResult[0].ProjectCode
                , Convert.ToInt32(dataResult[0].CMNumber).ToString("00")
                , dataResult[0].ApprovalAuhority
                , dataResult[0].CMDate.ToString("MMM")
                , dataResult[0].CMDate.ToString("yyyy")
                );

            foreach (DataRow item in listData.Rows)
            {
                if (item[3].ToString() == null || item[3].ToString().Trim().Length == 0)                 //ApprovalDate
                {
                    continue;
                }

                tblPreviousApproval.Rows.Add(ref missing);
                rowCounter++;

                tblPreviousApproval.Cell(rowCounter, 1).Range.Text = item[1].ToString();
                tblPreviousApproval.Cell(rowCounter, 1).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
                tblPreviousApproval.Cell(rowCounter, 1).Range.Paragraphs.Alignment           = WdParagraphAlignment.wdAlignParagraphLeft;
                tblPreviousApproval.Cell(rowCounter, 1).Range.Font.Name = currFontFamily;
                tblPreviousApproval.Cell(rowCounter, 1).Range.Font.Size = currFontSize;

                tblPreviousApproval.Cell(rowCounter, 2).Range.Text = item[2].ToString();
                tblPreviousApproval.Cell(rowCounter, 2).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
                tblPreviousApproval.Cell(rowCounter, 2).Range.Paragraphs.Alignment           = WdParagraphAlignment.wdAlignParagraphLeft;
                tblPreviousApproval.Cell(rowCounter, 2).Range.Font.Name = currFontFamily;
                tblPreviousApproval.Cell(rowCounter, 2).Range.Font.Size = currFontSize;

                tblPreviousApproval.Cell(rowCounter, 3).Range.Text = item[3].ToString();
                tblPreviousApproval.Cell(rowCounter, 3).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
                tblPreviousApproval.Cell(rowCounter, 3).Range.Paragraphs.Alignment           = WdParagraphAlignment.wdAlignParagraphLeft;
                tblPreviousApproval.Cell(rowCounter, 3).Range.Font.Name = currFontFamily;
                tblPreviousApproval.Cell(rowCounter, 3).Range.Font.Size = currFontSize;

                tblPreviousApproval.Cell(rowCounter, 4).Range.Text = Convert.ToDateTime(item[4].ToString()).ToString("dd MMM yyyy");
                tblPreviousApproval.Cell(rowCounter, 4).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
                tblPreviousApproval.Cell(rowCounter, 4).Range.Paragraphs.Alignment           = WdParagraphAlignment.wdAlignParagraphLeft;
                tblPreviousApproval.Cell(rowCounter, 4).Range.Font.Name = currFontFamily;
                tblPreviousApproval.Cell(rowCounter, 4).Range.Font.Size = currFontSize;

                string htmlResult = ConvertHtmlAndFile.SaveToFile(item[5].ToString());

                #region delete empty paragraph
                Application app2           = new Application();
                Document    sourceDocument = app2.Documents.Open(htmlResult);
                object      start          = sourceDocument.Content.Start;
                object      end            = sourceDocument.Content.End;
                Microsoft.Office.Interop.Word.Range myRange = sourceDocument.Range(ref start, ref end);
                myRange.Select();
                FindEmptyParagraphsAndDelete(sourceDocument);
                //myRange.set_Style(ref Normal);
                sourceDocument.Save();
                sourceDocument.Close(WdSaveOptions.wdSaveChanges);
                app2.Quit();
                #endregion

                tblPreviousApproval.Cell(rowCounter, 5).Range.InsertFile(htmlResult);
                tblPreviousApproval.Cell(rowCounter, 5).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
                tblPreviousApproval.Cell(rowCounter, 5).Range.Paragraphs.Alignment           = WdParagraphAlignment.wdAlignParagraphLeft;
                tblPreviousApproval.Cell(rowCounter, 5).Range.Font.Name = currFontFamily;
                tblPreviousApproval.Cell(rowCounter, 5).Range.Font.Size = currFontSize;
            }
        }