none
How to set table row height using c# RRS feed

  • Question

  • Hi, I want to create a report using word document.
    I just want to make my table row lower like the image below(the second table).

    Here's my code so far

    public static void createWord () { int row = 1; Microsoft.Office.Interop.Word.ApplicationClass app = new ApplicationClass(); app.Visible = true; object start = 0; object end = 0; object Null = System.Reflection.Missing.Value; object autofit = WdAutoFitBehavior.wdAutoFitFixed; Document doc = new DocumentClass(); doc = app.Documents.Add(ref Null, ref Null, ref Null, ref Null); //header____________________________________________________________________________________________________________________________ Microsoft.Office.Interop.Word.Paragraph header = doc.Paragraphs.Add(ref Null); header.Range.Text = "This is a header\nand this is sub header"; //header____________________________________________________________________________________________________________________________ Connection.open(); OleDbCommand selectstudent = new OleDbCommand("select * from bookstable where booksid=@a", Connection.connection); selectstudent.Parameters.AddWithValue("@a", L.StudInfo.studentid); OleDbDataReader readstudent = selectstudent.ExecuteReader(); OleDbCommand count = new OleDbCommand("select count(*) from bookstable where booksid=@a",Connection.connection); count.Parameters.AddWithValue("@a", L.StudInfo.studentid); //table____________________________________________________________________________________________________________________________ Microsoft.Office.Interop.Word.Table borrower = doc.Tables.Add(doc.Range(ref start, ref end), Convert.ToInt32(count.ExecuteScalar()), 5, ref Null, ref autofit); borrower.Range.Font.Name = "segoe ui light"; borrower.Range.Font.Size = 8; borrower.Range.Borders[WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; borrower.Borders.Enable = 1; borrower.AutoFitBehavior(WdAutoFitBehavior.wdAutoFitContent); borrower.AutoFitBehavior(WdAutoFitBehavior.wdAutoFitFixed); borrower.AllowAutoFit = true; while(readstudent.Read()) { string remarks = ""; borrower.Rows[row].Cells[1].Range.Text = readstudent.GetStringOrNull("btitle"); borrower.Rows[row].Cells[2].Range.Text = readstudent.GetStringOrNull("bauthor"); borrower.Rows[row].Cells[3].Range.Text = readstudent.GetStringOrNull("bcode"); borrower.Rows[row].Cells[4].Range.Text = readstudent.GetStringOrNull("bdateborrowed") + "\n" + readstudent.GetStringOrNull("btimeborrowed"); string ids = readstudent.GetStringOrNull("bookremarksid"); OleDbCommand selectremarks = new OleDbCommand("select * from remarkstable where remarksid = @a", Connection.connection); selectremarks.Parameters.AddWithValue("@a", ids); OleDbDataReader readreamarks = selectremarks.ExecuteReader(); while(readreamarks.Read()) { remarks += readreamarks.GetStringOrNull("count") + "-" + readreamarks.GetStringOrNull("datereturned") + "-" + readreamarks.GetStringOrNull("timereturned") + "-" + readreamarks.GetStringOrNull("remarks")+"\n"; } borrower.Rows[row].Cells[5].Range.Text = remarks; borrower.Rows[row].Height = 1; row++; } Connection.close(); }



    Wednesday, May 7, 2014 5:37 AM

Answers

All replies