ggreen86 / XLSX-Workbook-Class

VFP Class to Create an XLSX Workbook without Excel Automation or Installed
45 stars 16 forks source link

Ignore ampersand in sheet name #55

Closed DougHennig closed 3 years ago

DougHennig commented 3 years ago

An ampersand in a sheet name is invalid, so I updated CheckSheetName as follows:

*** DH 2021-06-10: handle "&" too
*lcSheetName = CHRTRAN(tcSheetName, ":\/?*", "_____")
lcSheetName = CHRTRAN(tcSheetName, ":\/?*&", "______")
ggreen86 commented 3 years ago

Doug--

I just opened Excel 2016 and created a test workbook with the sheet name using a & symbol:

https://user-images.githubusercontent.com/28057069/121587917-4ec24800-ca03-11eb-8fd6-f407b4436cbf.png

I saved the workbook; closed Excel and then reopened the workbook -- it still has the & with no errors. I believe when I was coding the exclusion list, I tried all the special characters in the sheet name directly in Excel to determine those that were invalid.

Greg


From: Doug Hennig @.> Sent: Thursday, June 10, 2021 3:07 PM To: ggreen86/XLSX-Workbook-Class @.> Cc: Subscribed @.***> Subject: [ggreen86/XLSX-Workbook-Class] Ignore ampersand in sheet name (#55)

An ampersand in a sheet name is invalid, so I updated CheckSheetName as follows:

** DH 2021-06-10: handle "&" too lcSheetName = CHRTRAN(tcSheetName, ":/?", "") lcSheetName = CHRTRAN(tcSheetName, ":/?&", "_")

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/ggreen86/XLSX-Workbook-Class/issues/55, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGWB33KDNOKUXU6KWZ762LLTSEENXANCNFSM46PD752A.

DougHennig commented 3 years ago

I created the attached document using SaveGridToWorkbookEx with "A & B" specfied as the sheet name. Excel says the file is corrupted and won't open it. With the change I noted above, the document opens correctly.

A & B.xlsx

ggreen86 commented 3 years ago

Doug--

I see the error -- the & is not getting encoded for the sheet name as shown:

https://user-images.githubusercontent.com/28057069/121594363-fc852500-ca0a-11eb-9d97-9729cbeaa0aa.png

I will look into this for a fix. It should have been:

https://user-images.githubusercontent.com/28057069/121594465-1888c680-ca0b-11eb-9c51-e48a5cdc563c.png

Greg


From: Doug Hennig @.> Sent: Thursday, June 10, 2021 4:26 PM To: ggreen86/XLSX-Workbook-Class @.> Cc: ggreen86 @.>; Comment @.> Subject: Re: [ggreen86/XLSX-Workbook-Class] Ignore ampersand in sheet name (#55)

I created the attached document using SaveGridToWorkbookEx with "A & B" specfied as the sheet name. Excel says the file is corrupted and won't open it. With the change I noted above, the document opens correctly.

A & B.xlsxhttps://github.com/ggreen86/XLSX-Workbook-Class/files/6634218/A.B.xlsx

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ggreen86/XLSX-Workbook-Class/issues/55#issuecomment-859027851, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGWB33IW72DOQMHILUAY3YLTSENYFANCNFSM46PD752A.

DougHennig commented 3 years ago

My mistake: I was using R33 Beta 6 not Beta 8. Sorry about that!