Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetColumnBestFit not working on numbers #90

Open
ARuddOS opened this issue Jun 16, 2023 · 1 comment
Open

SetColumnBestFit not working on numbers #90

ARuddOS opened this issue Jun 16, 2023 · 1 comment

Comments

@ARuddOS
Copy link

ARuddOS commented Jun 16, 2023

I am finding that SetColumnBestFit works well on text, but not so well on numbers, I have tested this on 39 beta 8.
The code below is rough and ready but does create an example.
I am not specifying the fonts to use in the cells, Excel is displaying in Calibri size 11

m.oVFPWorkBook = NEWOBJECT("vfpxworkbookxlsx","vfpxworkbookxlsx.vcx")
m.lnWb = m.oVFPWorkBook.CreateWorkbook(GETFILE("xlsx"))
m.lnSheet = m.oVFPWorkBook.AddSheet(m.lnWb)

m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 1, -10000)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 2, -1000)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 3, -100)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 4, -10)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 5, -1)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 6, 1)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 7, 10)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 8, 100)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 9, 1000)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 10, 10000)
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 11, "A Long string has been entered in this cell")
m.oVFPWorkBook.SetCellValue(m.lnWb, m.lnSheet, 1, 12, "A Long string has been entered in this cell")

m.lnNumberFormat = m.oVFPWorkBook.AddNumericFormat(m.lnWb, "0.00;")
m.oVFPWorkBook.SetCellNumberFormatRange(m.lnWb, m.lnSheet, 1, 1, 1, 10, m.lnNumberFormat)

m.oVFPWorkBook.SetCellNumberFormatRange(m.lnWb, m.lnSheet, 1, 11, 1, 12, 49)

FOR m.nN=1 TO 11
m.oVFPWorkBook.SetColumnBestFit(m.lnWb, m.lnSheet, m.nN, .T.)
ENDFOR

@ggreen86
Copy link
Owner

ggreen86 commented Jun 20, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants