[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP generated CSV file ... need to bold text...

Posted on 2004-11-18
14
Medium Priority
?
504 Views
Last Modified: 2008-01-09
im creating a CSV file on the fly using ASP and SQL, file is created fine and everything looks good. but i would like to bold the "headers" in the created file. anyone have any thoughts on how to go about that? tried to use simple HTML <b></b> tags, but no dice. any help appreciated!
0
Comment
Question by:fivezerotwo
14 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12617424
How would bold even  be displayed in a .txt file? Perhaps I don't undersand the question?

FtB
0
 

Author Comment

by:fivezerotwo
ID: 12617464
im building a string of comma seperated fields, that get written out to a file that is using the .csv extension... which should be picked up by Excel on most (clients) computers.

im basically just trying to bold the headers, using some "code" that Excel would recognize. im not even sure if this is a possibility, or if its possible with the method im using to create the file. just something that would make the file look a little cleaner. =)
0
 
LVL 14

Expert Comment

by:huji
ID: 12617504
Yes, we have bold things in Excel but they do not appear in Coma Seperateve files. You need XLS files for that. I myself don't have a good idea on how to export XLS files from ASP now.
Wish I can help
huji
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12617512
Okay, that is a different problem that at least in theory could have a solution, but I don't believe that such a code existsl

FtB
0
 

Assisted Solution

by:victhetech
victhetech earned 80 total points
ID: 12617545
Can you post the part of ASP the code where you tell your server to write the contents to the ASP page? I'm assuming you are using ASP code to extract data from SQL to be posted on an ASP page right? if so please post you code where this action happens on the ASP page. Please explain if I'm missing something
0
 

Author Comment

by:fivezerotwo
ID: 12617576
'''' grab and build the comma sep fields ''''
Set rsProof = cnProof.Execute(strSQL2)

'start to build comma seperated string....
'FILE HEADERS
strCommaList = ""
strCommaList = strCommaList & "Client Name, Store Number, Quantity, Display Phone, Display Address, "
strCommaList = strCommaList & "Display City, Store Hours 1, Store Hours 2, Four Color Creative, Gaurenteed Offer Set, "
strCommaList = strCommaList & "C1 Offer Code, C1 Price Point, "
strCommaList = strCommaList & "C2 Offer Code, C2 Price Point, "
strCommaList = strCommaList & "C3 Offer Code, C3 Price Point, "
strCommaList = strCommaList & "C4 Offer Code, C4 Price Point, "
strCommaList = strCommaList & "C5 Offer Code, C5 Price Point, "
strCommaList = strCommaList & "C6 Offer Code, C6 Price Point, "
strCommaList = strCommaList & "C7 Offer Code, C7 Price Point, "
strCommaList = strCommaList & "C8 Offer Code, C8 Price Point, "
strCommaList = strCommaList & "Shiping Company, Shipping Contact, Shipping Address, Shipping City, Shipping State, Shipping Zip, Shipping Phone, "
strCommaList = strCommaList & "Indicia, Indicia 1, Indicia 2, Indicia 3, Indicia 4, Indicia 5, "
strCommaList = strCommaList & "Delivery Date, CSR, Special Instructions " & VbCrLf

count = 1
With rsProof
      Do While Not .EOF
            'FILE DATA
                  strCommaList = strCommaList & .Fields("ClientName") & ", " & .Fields("StoreNum") & ", " & .Fields("Qty") & ", "
                  strCommaList = strCommaList & .Fields("DisplayPhone") & ", " & .Fields("DisplayAddress") & ", " & .Fields("DisplayCity") & ", "
                  strCommaList = strCommaList & .Fields("StoreHours1") & ", " & .Fields("StoreHours2") & ", " & .Fields("FourColorCreative") & ", "
                  strCommaList = strCommaList & .Fields("GaurenteedOfferSet") & ", " & .Fields("C1OfferCode") & ", " & .Fields("C1PricePoint") & ", "
                  strCommaList = strCommaList & .Fields("C2OfferCode") & ", " & .Fields("C2PricePoint") & ", " & .Fields("C3OfferCode") & ", "
                  strCommaList = strCommaList & .Fields("C3PricePoint") & ", " & .Fields("C4OfferCode") & ", " & .Fields("C4PricePoint") & ", "
                  strCommaList = strCommaList & .Fields("C5OfferCode") & ", " & .Fields("C5PricePoint") & ", " & .Fields("C6OfferCode") & ", "
                  strCommaList = strCommaList & .Fields("C6PricePoint") & ", " & .Fields("C7OfferCode") & ", " & .Fields("C7PricePoint") & ", "
                  strCommaList = strCommaList & .Fields("C8OfferCode") & ", " & .Fields("C8PricePoint") & ", " & .Fields("ShipingCompany") & ", "
                  strCommaList = strCommaList & .Fields("ShippingContact") & ", " & .Fields("ShippingAddress") & ", " & .Fields("ShippingCity") & ", "
                  strCommaList = strCommaList & .Fields("ShippingState") & ", " & .Fields("ShippingZip") & ", " & .Fields("ShippingPhone") & ", "
                  strCommaList = strCommaList & .Fields("Indicia") & ", " & .Fields("Indicia1") & ", " & .Fields("Indicia2") & ", "
                  strCommaList = strCommaList & .Fields("Indicia3") & ", " & .Fields("Indicia4") & ", " & .Fields("Indicia5") & ", "
                  strCommaList = strCommaList & .Fields("DeliveryDate") & ", " & .Fields("CSR") & ", " & .Fields("SpecialInstructions") & "" & VbCrLf
            count = count + 1
            rsProof.MoveNext
      Loop
End With



'''' build the file ''''
sDay = Day(Now)
sMonth = Month(Now)
sYear = Year(Now)
sHour = Hour(Now)
sMinute = Minute(Now)
strDateName = sDay & sMonth & sYear & "-" & sHour & sMinute

strLink = strDirectory & strUserID & "_" & strDateName & "_Report.csv"
strLinkToFile = strUserID & "_" & strDateName & "_Report.csv"
strDownloadLink = "<a href=""reports/" & strLinkToFile & """>Download Report Results</a>"

'set fso = CreateObject("Scripting.FileSystemObject")
'set fs = fso.CreateTextFile(strDirectory & strUserID & "_" & strDateName & "_Report.csv", true)
'      fs.writeline(strCommaList)
'      fs.close
'set fs = nothing
'set fso = nothing
0
 
LVL 10

Assisted Solution

by:ALaRiva
ALaRiva earned 80 total points
ID: 12617653
One option, since you are planning on having the people use the file in Excel, is to just stream out an excel file to the user instead.  It'll be much quicker, and you can have you own formatting.

Remember, Excel understands HTML Tables, and inline style formatting, so you could easily do this.

Just an option

-Anthony
0
 
LVL 5

Assisted Solution

by:kollu
kollu earned 80 total points
ID: 12617718
You can build a  HTML with bold tag to headers and export to excel from asp page.You develop separate asp page with
Response.Clear
Response.ContentType = "application/vnd.ms-excel"  
and you database code with Html bold tags.This should work fine
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 80 total points
ID: 12617721
Anthony has a good point there. It is as easy as this (if you bold the table headers it should come over to Excel):

<%
dim strDataPath, strConnectString  
dim objConnection, objRS

'set connection strings for entire application
strDataPath = server.MapPath("Family.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;"_
                  + " Data Source= " & strDataPath & ";"_
                  + " Mode=Share Deny None;User Id=admin;PASSWORD=;"

if not IsObject("ojbConnection") then
      set objConnection=Server.CreateObject("ADODB.Connection")
      objConnection.ConnectionTimeout = 15
      objConnection.CommandTimeout =  10
      objConnection.Mode = 3 'adModeReadWrite
      if objConnection.state = 0 then
            objConnection.Open strConnectString
      end if
end if


set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "Select * from Person", objConnection,3,3

%>
<html>
<body>
<%Response.Clear%>
<%response.ContentType="application/vnd.ms-excel"%>

<%
Response.Write("<Table Border=1 cellpadding=2 cellspacing=2>")
Response.Write("<TR>")
for intCounter = 0  to objRS.Fields.count-1
      Response.Write("<TD>" & objRS(intCounter).Name & "</TD>")
next
Response.Write("</TR>")
for i=1 to objRS.RecordCount
      Response.Write("<TR>")
      for j=0 to objRS.Fields.count-1
            Response.Write("<TD>" & objRS(j).Value & "</TD>")
      next
      Response.Write("</TR>")
      objRS.MoveNext
next
%>
</Table>
</body>
</html>
<%
if objRS.State <> 0 then objRS.Close
set objRS = Nothing
if objConnection.state <> 0 then objConnection.Close
set objConnection = Nothing
Response.End
%>
0
 
LVL 11

Expert Comment

by:sciber_dude
ID: 12617830
@ Ftb -

Dont you have to have the following lines right on top of the page?

<%Response.Clear%>
<%response.ContentType="application/vnd.ms-excel"%>

coz it would throw an error.

:) SD
0
 
LVL 9

Assisted Solution

by:AgentSmith007
AgentSmith007 earned 80 total points
ID: 12618304
fivezerotwo,

Unfortunately, the .csv (comma-seperated values) format does not support text formatting readable by MS Excel. It's simply a means of storing comma seperated values. The above solutions would enable to acheive your goal of applying formatting, however would not meet the criteria of being .csv files.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12618314
SD--

I have run the above without problem. When I get a minute, I'll run it again to make certain.

FtB
0
 

Author Comment

by:fivezerotwo
ID: 12618505
i think the client is just going to have to deal with out a bold. what i have has been implemented in too many places to try and go back to clean up. wouldve been nice to get the bold in there, but hey, they only pay for so much time. hehehe. thanks to all who responded, im going to split the measly points up. thanks again all!
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12618590
Glad to have helped, and good luck.

FtB
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question