export to CSV file plz help

Steam5

New member
Joined
Aug 29, 2006
Messages
3
Programming Experience
Beginner
Hi,
I'm trying to export to CSV file and change the color of the cell i've write the code below but it's not working.

VB.NET:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ssFile As String = Server.MapPath("גדי.csv")
Dim xlApp As Excel.Application = New Excel.Application
Dim xlbooks As Excel.Workbook
Dim xlsheet As Excel.Worksheet
 
Try
xlbooks = xlApp.Workbooks.Open(ssFile)
xlsheet = xlbooks.Sheets("גדי")
xlsheet.Range("I9").Interior.ColorIndex = 4
xlbooks.Save()
Catch ex As Exception
MsgBox(ex.Message.ToString())
Finally
xlbooks.Close(True)
xlApp.Quit()
xlsheet = Nothing
xlbooks = Nothing
xlApp = Nothing
End Try
End Sub

i'll be more than happy if you can help me 10x.
 
Last edited by a moderator:
You can't change the colour of "cells" in a CSV file because the format doesn't support it. You can apply colours while it's open in Excel but as soon as you save all that is lost, because all a CSV file saves is the data and nothing else. That's why you get a warning in Excel that some functionality may be lost if you save to CSV. If you want fancy featuresa like that then you'll need to use the XLS file format.
 
Back
Top