locked
How to Have Bottom Border Programmatically in Export Excel File RRS feed

  • Question

  • User989035446 posted

    Hi, i need to have bottom border programmatically in export excel file.

    I have search online but has no idea in having having bottom border in exportes excel file programmactically.

    Does anyone has idea on this?

    Help Please!!

    Sunday, February 6, 2011 9:10 AM

Answers

  • User-158764254 posted

    i believe excel will read the various styles assigned to the cells if you feed it an html table.

    So if you are writing out the cell for a new group, you could try sending: "<td style='border-top: 1px solid #000000;'>"

    you ned to keep track of the last value of value1 when you are looping so you know when to send the border style

    if value1 <> peviousValue1 then
        send the td markup with the border
    else
        send a plain tds
    end if
    peviousValue1 = value1

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 6, 2011 10:58 AM
  • User-2119480821 posted

    To draw a line...

    Response.Write("<hr width='100px' />")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 6, 2011 11:13 AM

All replies

  • User-158764254 posted

    there is a free open source component for reading/writing to excel files that may give you the ability to control the cell formatting of the output.

    http://npoi.codeplex.com/ 

    Sunday, February 6, 2011 10:36 AM
  • User989035446 posted

    Hi mbanavige, my sample code is as below:

     Response.Write("<table>")
    
      Response.Write("<tr>")
         Response.Write("<td>")
            Reponse.Write("Value1")
         Response.Write("</td>")
    
         Response.Write("<td>")
            Reponse.Write("Valuex2")
         Response.Write("</td>")
    
       Response.Write("</tr>")
     Response.Write("</table>")
    
    


    The excel format should look like below:

    ------------------------------------------------ (How to draw this line?)
    Column1 Column2  |
    Value1   Valuex2   |
    Value1   Valuey2   |
    Value1   Valuez2   |
    -----------------------------------------------( How to draw this line?)
    Value3   Valuex3   |
    Value3   Valuey3   |
    Value3   Valuez3   |
    --------------------------------------------------------

    I find no way to have the line in between group of data.

    Do you have any idea to do this?

    Sunday, February 6, 2011 10:48 AM
  • User-158764254 posted

    i believe excel will read the various styles assigned to the cells if you feed it an html table.

    So if you are writing out the cell for a new group, you could try sending: "<td style='border-top: 1px solid #000000;'>"

    you ned to keep track of the last value of value1 when you are looping so you know when to send the border style

    if value1 <> peviousValue1 then
        send the td markup with the border
    else
        send a plain tds
    end if
    peviousValue1 = value1

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 6, 2011 10:58 AM
  • User-2119480821 posted

    To draw a line...

    Response.Write("<hr width='100px' />")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 6, 2011 11:13 AM
  • User989035446 posted

    Hi mbanavige,suthish nair

    Thank you very much...

    You guys has helped me a lot..

    My sample code is as below:

    Response.Write("<table style='border-collapse: collapse; border: solid;'>")
                    Response.Write("<tr ><td style='border-right: 3px solid black;' >Morning</td> <td>x1</td></tr>")
                    Response.Write("<tr><td style='border-right: 3px solid black;'>Afternoon</td><td>x2</td></tr>")
                    Response.Write("<tr style='border-top: 20px solid #000000; border-right: 20px '><td style='border-right: 3px solid black;'>Evening</td><td>x3</td></tr>")
                    Response.Write("<tr ><td style='border-right: 3px solid black;'>Night</td><td>x4</td></tr>")
    
                    Response.Write("</table>")




    Sunday, February 6, 2011 8:19 PM