Example #1
0
        private void wordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog2.Filter           = "doc files (*.doc)|*.doc|All files (*.*)|*.*";
            saveFileDialog2.FilterIndex      = 2;
            saveFileDialog2.RestoreDirectory = true;

            if (saveFileDialog2.ShowDialog() == DialogResult.OK)
            {
                Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
                Object        missing = Type.Missing;
                Word.Document word1   = application.Documents.Add(ref missing, ref missing, ref missing, ref missing);
                //object text = "tesfsdfkslghsdgjh";
                //word1.Paragraphs[1].Range.InsertParagraphAfter();
                //word1.Paragraphs[1].Range.Text = "asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
                //word1.Footnotes.Location = Word.WdFootnoteLocation.wdBeneathText;
                //word1.Footnotes.NumberStyle = Word.WdNoteNumberStyle.wdNoteNumberStyleLowercaseRoman;
                //word1.Footnotes.Add(word1.Paragraphs[1].Range.Words[2].Characters[2], ref missing, ref text);
                Microsoft.Office.Interop.Word.Document doc   = application.ActiveDocument;
                Microsoft.Office.Interop.Word.Range    range = doc.Paragraphs[doc.Paragraphs.Count].Range;
                dataSetTemp = dbw1.ReadMetricsByReport(listView2.Items[listView2.SelectedIndices[0]].Text);
                doc.Tables.Add(range, dataSetTemp.Tables[0].Rows.Count + 1, 6, ref missing, ref missing);
                doc.Tables[1].Cell(1, 1).Range.Text = "NAME metric";
                doc.Tables[1].Cell(1, 2).Range.Text = "MIN value";
                doc.Tables[1].Cell(1, 3).Range.Text = "CUR value";
                doc.Tables[1].Cell(1, 4).Range.Text = "MAX value";
                doc.Tables[1].Cell(1, 5).Range.Text = "VALUE";
                doc.Tables[1].Cell(1, 6).Range.Text = "RATE";
                for (int i = 0; i < dataSetTemp.Tables[0].Rows.Count; i++)
                {
                    dataSetTemp1 = dbw1.ReadInfoMetricByReportMetric(listView2.Items[listView2.SelectedIndices[0]].Text, dataSetTemp.Tables[0].Rows[i].ItemArray[0].ToString());
                    doc.Tables[1].Cell(i + 2, 1).Range.Text = dataSetTemp.Tables[0].Rows[i].ItemArray[0].ToString();
                    doc.Tables[1].Cell(i + 2, 2).Range.Text = dataSetTemp1.Tables[0].Rows[0].ItemArray[2].ToString();
                    doc.Tables[1].Cell(i + 2, 3).Range.Text = dataSetTemp1.Tables[0].Rows[0].ItemArray[0].ToString();
                    doc.Tables[1].Cell(i + 2, 4).Range.Text = dataSetTemp1.Tables[0].Rows[0].ItemArray[3].ToString();
                    doc.Tables[1].Cell(i + 2, 5).Range.Text = Double.Parse(dataSetTemp1.Tables[0].Rows[0].ItemArray[4].ToString()).ToString("F5");
                    doc.Tables[1].Cell(i + 2, 6).Range.Text = dataSetTemp1.Tables[0].Rows[0].ItemArray[5].ToString();
                }
                doc.Tables[1].Columns.AutoFit();
                Word.Border[] borders = new Word.Border[6];
                Word.Table    tbl     = doc.Tables[doc.Tables.Count];
                borders[0] = tbl.Borders[Word.WdBorderType.wdBorderLeft];
                borders[1] = tbl.Borders[Word.WdBorderType.wdBorderRight];
                borders[2] = tbl.Borders[Word.WdBorderType.wdBorderTop];
                borders[3] = tbl.Borders[Word.WdBorderType.wdBorderBottom];
                borders[4] = tbl.Borders[Word.WdBorderType.wdBorderHorizontal];
                borders[5] = tbl.Borders[Word.WdBorderType.wdBorderVertical];
                foreach (Word.Border border in borders)
                {
                    border.LineStyle = Word.WdLineStyle.wdLineStyleSingle;
                    border.Color     = Word.WdColor.wdColorBlack;
                }
                application.Documents[word1].SaveAs(saveFileDialog2.FileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                application.Quit();
                string info = "Doc file saved at\n" + saveFileDialog2.FileName;
                MessageBox.Show(this, info, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     checkedListBox1.Items.Clear();
     if (comboBox1.SelectedIndex == 0)
     {
         dataSet1 = dbw1.ReadFartorsByReport(g_reportName);
     }
     if (comboBox1.SelectedIndex == 1)
     {
         dataSet1 = dbw1.ReadCriteriasByReport(g_reportName);
     }
     if (comboBox1.SelectedIndex == 2)
     {
         dataSet1 = dbw1.ReadMetricsByReport(g_reportName);
     }
     parametrs = new double[0];
     this.Invalidate();
     for (int i = 0; i < dataSet1.Tables[0].Rows.Count; i++)
     {
         checkedListBox1.Items.Add(dataSet1.Tables[0].Rows[i].ItemArray[0].ToString(), false);
     }
 }