2

How would I force cell formatting to take effect automatically after a data refresh?

I have a connection set up to pull data from SQL Server to a table in Excel.

However, upon initial pull and refresh - cell formatting does not take effect on these cells, until I interact with them in some way such as double-clicking, or pressing F2, or even using Text To Columns to fix them all at once.

My settings indicate to preserve cell formatting, and it is preserved, it just doesn't seem to apply until interaction of some kind occurs.

External Data Properties Settings

See here before and after shots:

Before Interaction After Interaction

The issue is affecting formatting of my entire table, the specific column shown IS a date type in SQL Server.

Is there something I'm completely overlooking to have cell formatting apply to cells after data refresh, or if this is just a bug in Excel, would it be possible to maybe macro out a Text To Columns action after every data refresh?

I'm on Excel 2013, with SQL Server 2008 R2.

Any help appreciated, Thanks.

EDIT 1: No formulas exist in table, has been tested on multiple machines and on Excel 2013 and 2016 and issue still occurs.

Community
  • 1
  • 1

1 Answers1

2

I think this is an issue of Excel not recognizing your data as a date. Try this cast for your date from SQL:

CAST(YourDate AS smalldatetime) "Date"
justiceorjustus
  • 2,017
  • 1
  • 19
  • 42
  • This worked, apparently the SQL Datatype of `date` doesn't translate well to Excel, however smalldatetime is perfect. I originally had the definition command type set to Table, changing it to SQL and manually selecting every column with some being cast as more Excel-Friendly datatypes worked perfectly! – RoflcopterV RoflcopterV Aug 22 '17 at 20:02
  • @RoflcopterVRoflcopterV Glad to help! – justiceorjustus Aug 22 '17 at 20:04