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

Assuming Header name is Header1 #102

Closed
DougHennig opened this issue Dec 4, 2023 · 4 comments
Closed

Assuming Header name is Header1 #102

DougHennig opened this issue Dec 4, 2023 · 4 comments

Comments

@DougHennig
Copy link

There are a few places that assume the Header object of a column is named Header1 but it may not be. Here's the fix:

  • SaveGridToWorkbook:
IF toGrid.HeaderHeight > 0                                                    && Change recommendation by Doug Hennig (if no headers, start in first row)
	lnRow = 1
	FOR lnCol=1 TO lnColCount
		loColumn = toGrid.Columns(laColOrder[lnCol, 2])
*** DH 2023-12-04: don't assume the header object is named Header1
*		this.SetCellValue(lnWB, lnSh, 1, lnCol, loColumn.Header1.Caption)
		loHeader = loColumn.Controls[1]
		this.SetCellValue(lnWB, lnSh, 1, lnCol, loHeader.Caption)
*** DH 2023-12-04: end of change
		this.SetCellStyle(lnWB, lnSh, 1, lnCol, loGrid.Columns(laColOrder[lnCol, 2]).HeaderStyleId)
		this.SetColumnWidth(lnWB, lnSh, lnCol, this.ConvertPixelsToExcelUnits(loColumn.Width))
	ENDFOR
  • GetColumnObject:
*** DH 2023-12-04: don't assume the header object is named Header1
*ADDPROPERTY(loColumn, "HeaderCaption", toGridColumn.Header1.Caption)
*ADDPROPERTY(loColumn, "HeaderFontBold", toGridColumn.Header1.FontBold)
*ADDPROPERTY(loColumn, "HeaderFontItalic", toGridColumn.Header1.FontItalic)
*ADDPROPERTY(loColumn, "HeaderFontName", toGridColumn.Header1.FontName)
*ADDPROPERTY(loColumn, "HeaderFontSize", toGridColumn.Header1.FontSize)
loHeader = toGridColumn.Controls[1]
ADDPROPERTY(loColumn, "HeaderCaption", loHeader.Caption)
ADDPROPERTY(loColumn, "HeaderFontBold", loHeader.FontBold)
ADDPROPERTY(loColumn, "HeaderFontItalic", loHeader.FontItalic)
ADDPROPERTY(loColumn, "HeaderFontName", loHeader.FontName)
ADDPROPERTY(loColumn, "HeaderFontSize", loHeader.FontSize)
*** DH 2023-12-04: end of change
  • SaveMultiGridToWorkbookEx: I didn't make the change but it's the same fix (two places)
@ggreen86
Copy link
Owner

ggreen86 commented Dec 21, 2023 via email

@DougHennig
Copy link
Author

Here's the code for version 39.

  • SaveGridToWorkbook: beginning at line 212:
IF toGrid.HeaderHeight > 0                                                    && Change recommendation by Doug Hennig (if no headers, start in first row)
	lnRow = tnBegRow
	FOR lnCol=1 TO lnColCount
		loColumn = toGrid.Columns(laColOrder[lnCol, 2])
*** DH 2023-12-04: don't assume the header object is named Header1
*		this.SetCellValue(lnWB, lnSh, lnRow, lnCol+tnBegCol-1, loColumn.Header1.Caption)
		loHeader = loColumn.Controls[1]
		this.SetCellValue(lnWB, lnSh, lnRow, lnCol+tnBegCol-1, loHeader.Caption)
*** DH 2023-12-04: end of change
		this.SetCellStyle(lnWB, lnSh, lnRow, lnCol+tnBegCol-1, loGrid.Columns(laColOrder[lnCol, 2]).HeaderStyleId)
		this.SetColumnWidth(lnWB, lnSh, lnCol+tnBegCol-1, this.ConvertPixelsToExcelUnits(loColumn.Width))
	ENDFOR
  • GetColumnObject: beginning at line 23:
*** DH 2023-12-04: don't assume the header object is named Header1
*ADDPROPERTY(loColumn, "HeaderCaption", toGridColumn.Header1.Caption)
*ADDPROPERTY(loColumn, "HeaderFontBold", toGridColumn.Header1.FontBold)
*ADDPROPERTY(loColumn, "HeaderFontItalic", toGridColumn.Header1.FontItalic)
*ADDPROPERTY(loColumn, "HeaderFontName", toGridColumn.Header1.FontName)
*ADDPROPERTY(loColumn, "HeaderFontSize", toGridColumn.Header1.FontSize)
loHeader = toGridColumn.Controls[1]
ADDPROPERTY(loColumn, "HeaderCaption", loHeader.Caption)
ADDPROPERTY(loColumn, "HeaderFontBold", loHeader.FontBold)
ADDPROPERTY(loColumn, "HeaderFontItalic", loHeader.FontItalic)
ADDPROPERTY(loColumn, "HeaderFontName", loHeader.FontName)
ADDPROPERTY(loColumn, "HeaderFontSize", loHeader.FontSize)
*** DH 2023-12-04: end of change

Merry Christmas to you and your family!

@DougHennig
Copy link
Author

I still see this issue in version 44.

@ggreen86
Copy link
Owner

ggreen86 commented Oct 2, 2024

I believe I have added the code fix for the header1 to R46. I will be sending you a test version directly. I will be releasing initially as a beta.

@ggreen86 ggreen86 closed this as completed Oct 3, 2024
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