OLEDB implemintation question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I working with Excel file by using the OLEDB components such :
OleDbConnection ,OleDbCommand.
I successfuly read/update the Excel table.
The problem is how can I change the color of spicific location, I can update
spicifc value by somthing like :
_oleCmdUpdate =new OleDbCommand(
@" Update ["
+ _strSheetName
"$" + _strSheetRange
+ "] set F1=" + strVal, _oleConn);

How can I change color this spicific location in Excel table, I find
somthing in VB not C# , any one can convert tho following VB code to C# ? How
can do the same in C#?

Sub ColorCells()
On Error Resume Next
With Sheet1.UsedRange
.SpecialCells(xlCellTypeFormulas).Font.Color = vbBlack
.SpecialCells(xlCellTypeConstants).Font.Color = vbBlue
End With
On Error GoTo 0
End Sub
 
void ColorCells()
{
try
{
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas].Font.Color =
vbBlack
Sheet1.UsedRange..SpecialCells[xlCellTypeConstants].Font.Color =
vbBlue
}
catch
{
}
}

Not quite sure if it should be
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas] or
Sheet1.UsedRange.SpecialCells(xlCellTypeFormulas)
See which one works
 
How this become an OLEdb commands ?
I don't have sheet1 , to access sheet1 I should do somthing like :
_oleCmdSelect =new OleDbCommand(
@"SELECT * FROM ["
+ _strSheetName
+ "$" + _strSheetRange
+ "]", _oleConn);

How can I merge your code to such a commands for OLEDB transactions ?
Your Sheet1 is Excel.Worksheet Sheet1 but I don't use Excel namespace,
This exactly what I need how to do the same using OLEDB ?
Thx.


Alex Feinman said:
void ColorCells()
{
try
{
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas].Font.Color =
vbBlack
Sheet1.UsedRange..SpecialCells[xlCellTypeConstants].Font.Color =
vbBlue
}
catch
{
}
}

Not quite sure if it should be
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas] or
Sheet1.UsedRange.SpecialCells(xlCellTypeFormulas)
See which one works

--
Alex Feinman
---
Visit http://www.opennetcf.org
I working with Excel file by using the OLEDB components such :
OleDbConnection ,OleDbCommand.
I successfuly read/update the Excel table.
The problem is how can I change the color of spicific location, I can
update
spicifc value by somthing like :
_oleCmdUpdate =new OleDbCommand(
@" Update ["
+ _strSheetName
"$" + _strSheetRange
+ "] set F1=" + strVal, _oleConn);

How can I change color this spicific location in Excel table, I find
somthing in VB not C# , any one can convert tho following VB code to C# ?
How
can do the same in C#?

Sub ColorCells()
On Error Resume Next
With Sheet1.UsedRange
.SpecialCells(xlCellTypeFormulas).Font.Color = vbBlack
.SpecialCells(xlCellTypeConstants).Font.Color = vbBlue
End With
On Error GoTo 0
End Sub
 
As told you before, you can't use the Excel object model without having
Excel installed, that means you can't access workbook/sheet properties.
Using OLEDB and the text provider only allows you to access the data in a
file in tabular form (like an Excel spreadsheet), but that's it.

Willy.

How this become an OLEdb commands ?
I don't have sheet1 , to access sheet1 I should do somthing like :
_oleCmdSelect =new OleDbCommand(
@"SELECT * FROM ["
+ _strSheetName
+ "$" + _strSheetRange
+ "]", _oleConn);

How can I merge your code to such a commands for OLEDB transactions ?
Your Sheet1 is Excel.Worksheet Sheet1 but I don't use Excel namespace,
This exactly what I need how to do the same using OLEDB ?
Thx.


Alex Feinman said:
void ColorCells()
{
try
{
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas].Font.Color =
vbBlack
Sheet1.UsedRange..SpecialCells[xlCellTypeConstants].Font.Color =
vbBlue
}
catch
{
}
}

Not quite sure if it should be
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas] or
Sheet1.UsedRange.SpecialCells(xlCellTypeFormulas)
See which one works

--
Alex Feinman
---
Visit http://www.opennetcf.org
I working with Excel file by using the OLEDB components such :
OleDbConnection ,OleDbCommand.
I successfuly read/update the Excel table.
The problem is how can I change the color of spicific location, I can
update
spicifc value by somthing like :
_oleCmdUpdate =new OleDbCommand(
@" Update ["
+ _strSheetName
"$" + _strSheetRange
+ "] set F1=" + strVal, _oleConn);

How can I change color this spicific location in Excel table, I find
somthing in VB not C# , any one can convert tho following VB code to C#
?
How
can do the same in C#?

Sub ColorCells()
On Error Resume Next
With Sheet1.UsedRange
.SpecialCells(xlCellTypeFormulas).Font.Color = vbBlack
.SpecialCells(xlCellTypeConstants).Font.Color = vbBlue
End With
On Error GoTo 0
End Sub
 
"Using OLEDB and the text provider only allows you to access the data in a
file in tabular form (like an Excel spreadsheet), but that's it." : this
clarify everything.

"that means you can't access workbook/sheet properties.Using OLEDB" : I
didn't read such before .

Any way I get think I have all the information for how to use the Excel, now
my app can decide whether to use Excel library or OLEODB depending on the
local machine includes Excel app or not.

Thanks a lot.

Regards,
Yosef
Willy Denoyette said:
As told you before, you can't use the Excel object model without having
Excel installed, that means you can't access workbook/sheet properties.
Using OLEDB and the text provider only allows you to access the data in a
file in tabular form (like an Excel spreadsheet), but that's it.

Willy.

How this become an OLEdb commands ?
I don't have sheet1 , to access sheet1 I should do somthing like :
_oleCmdSelect =new OleDbCommand(
@"SELECT * FROM ["
+ _strSheetName
+ "$" + _strSheetRange
+ "]", _oleConn);

How can I merge your code to such a commands for OLEDB transactions ?
Your Sheet1 is Excel.Worksheet Sheet1 but I don't use Excel namespace,
This exactly what I need how to do the same using OLEDB ?
Thx.


Alex Feinman said:
void ColorCells()
{
try
{
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas].Font.Color =
vbBlack
Sheet1.UsedRange..SpecialCells[xlCellTypeConstants].Font.Color =
vbBlue
}
catch
{
}
}

Not quite sure if it should be
Sheet1.UsedRange.SpecialCells[xlCellTypeFormulas] or
Sheet1.UsedRange.SpecialCells(xlCellTypeFormulas)
See which one works

--
Alex Feinman
---
Visit http://www.opennetcf.org
I working with Excel file by using the OLEDB components such :
OleDbConnection ,OleDbCommand.
I successfuly read/update the Excel table.
The problem is how can I change the color of spicific location, I can
update
spicifc value by somthing like :
_oleCmdUpdate =new OleDbCommand(
@" Update ["
+ _strSheetName
"$" + _strSheetRange
+ "] set F1=" + strVal, _oleConn);

How can I change color this spicific location in Excel table, I find
somthing in VB not C# , any one can convert tho following VB code to C#
?
How
can do the same in C#?

Sub ColorCells()
On Error Resume Next
With Sheet1.UsedRange
.SpecialCells(xlCellTypeFormulas).Font.Color = vbBlack
.SpecialCells(xlCellTypeConstants).Font.Color = vbBlue
End With
On Error GoTo 0
End Sub
 
Back
Top