View unanswered posts | View active topics
It is currently Thu Nov 21, 2024 4:04 pm
|
Page 1 of 1
|
[ 6 posts ] |
|
Author |
Message |
opingo
Joined: Wed May 24, 2023 1:00 am Posts: 6
|
Autofit Column in VB 6
I have Following Query for EasyXLS for VB 6 for doing Autofit of Column
How to do Autofit all the column ?
I have tried the Following xlsFirstTable.setColumnWidth -1 Autofit does not work and Excel File Gives Error while opening saying that It has found unreadable contenet in Excel File
xlsFirstTable.setColumnWidth 0 It does work many times, but it does not work with Numbers.
Following is the Code which I have Tried.
Dim workbook Dim xlsFirstTable Dim xlsStyleBold
Set workbook = CreateObject("EasyXLS.ExcelDocument") Set xlsStyleBold = CreateObject("EasyXLS.ExcelStyle")
workbook.easy_addWorksheet_2 ("S1") Set xlsFirstTable = workbook.easy_getSheetAt(0).easy_getExcelTable() xlsFirstTable.setColumnWidth 0 xlsFirstTable.easy_getCell(0, 0).setValue ("Sheet 1") xlsFirstTable.easy_getCell(4, 0).setValue ("Column 1") xlsFirstTable.easy_getCell(4, 1).setValue ("Column 2") xlsFirstTable.easy_getCell(4, 2).setValue ("3") xlsFirstTable.easy_getCell(4, 3).setValue ("Column 4") xlsFirstTable.easy_getCell(4, 4).setValue ("Column 5") xlsFirstTable.easy_getCell(4, 5).setValue ("Column 6") xlsFirstTable.easy_getCell(4, 6).setValue ("Column 7") xlsFirstTable.easy_getCell(4, 7).setValue ("8") xlsFirstTable.easy_getCell(4, <- src="{SMILIES_PATH}/icon_cool.gif" alt="8)" title="Cool" />.setValue ("Column 9") xlsFirstTable.easy_getCell(4, 9).setValue ("Column 10") xlsFirstTable.easy_getCell(4, 10).setValue ("10") xlsFirstTable.easy_getCell(4, 11).setValue ("Column 11") xlsFirstTable.easy_getCell(4, 12).setValue ("12") xlsFirstTable.easy_getCell(5, 2).setValue ("321") xlsFirstTable.easy_getCell(5, 5).setValue ("Column 6 Value 123") xlsFirstTable.easy_getCell(5, 7).setValue (123456789.12) xlsFirstTable.easy_getCell(5, 10).setValue (12345.12) xlsFirstTable.easy_getCell(5, 7).setDataType ("numeric") xlsFirstTable.easy_getCell(5, 10).setDataType ("numeric") xlsStyleBold.setBold (True) xlsStyleBold.setHorizontalAlignment ("center")
Err = xlsFirstTable.easy_setRangeStyle(4, 0, 4, 12, xlsStyleBold) = True str1 = App.Path + "\Test.xlsx" workbook.easy_WriteXLSXFile (str1)
Now in the above Code You need to Check Column H and Column K. It does not Authfir
Can You Help me to correct the above Code or give the Sample code to do AutoFit of the all the column in VB 6.0?
Thanking You,
Bhavesh
|
Wed Aug 16, 2023 2:49 pm |
|
|
daniela
Joined: Fri Feb 03, 2006 12:23 pm Posts: 199 Location: Brasov, Romania
|
Re: Autofit Column in VB 6
Hi, ExcelTable.setColumnWidth(int) method having one parameter sets the default column width and usually is visible for undefined columns. ExcelTable.setColumnWidth(int,int) method having two parameters sets the column width for a specific column: https://www.easyxls.com/manual/API_Documentation/EasyXLS/ExcelTable.html#setColumnWidth(int,int)In your case, if you don't set the column width, it should be automatically computed. This is the default behavior. Related to your code, the part with the GIF image does not appear to be right.
_________________ EasyXLS Team .NET and Java library to read and write Excel files Facebook X Reddit LinkedIn
|
Fri Aug 18, 2023 8:45 am |
|
|
opingo
Joined: Wed May 24, 2023 1:00 am Posts: 6
|
Re: Autofit Column in VB 6
Dear Daniela,
I have already gone through the Links but I am not able to find the Solution Inspite of Trying Multiple times.
Kindly find Project with the Source Code and this will generate the Excel File.
Thanking You,
Bhavesh
|
Mon Aug 21, 2023 6:02 am |
|
|
daniela
Joined: Fri Feb 03, 2006 12:23 pm Posts: 199 Location: Brasov, Romania
|
Re: Autofit Column in VB 6
Between the following lines, the first one is better because setValue method accepts string parameter: The column width seams fine for all columns. No data is truncated. The numeric values have indeed a small gap in front of the value, but this assures extra space for complex number formats.
_________________ EasyXLS Team .NET and Java library to read and write Excel files Facebook X Reddit LinkedIn
|
Mon Aug 28, 2023 8:02 am |
|
|
opingo
Joined: Wed May 24, 2023 1:00 am Posts: 6
|
Re: Autofit Column in VB 6
Dear Daniela,
I am uploading the Screen Shots and Excel Files
This is the Current Auto Fit.
Check Colum H and K and You will find the Extra Space
Is there any Way to Remove the Extra Spaces ?
Bhavesh
|
Thu Aug 31, 2023 7:08 am |
|
|
daniela
Joined: Fri Feb 03, 2006 12:23 pm Posts: 199 Location: Brasov, Romania
|
Re: Autofit Column in VB 6
Hi,
If you keep the value as numeric, it will keep an extra space reserved in front of the value for any eventual formatting. It is not possible to remove the extra space in this case. If you will set a data type as string for the numeric value, the space will disappear, but if you will use the cell inside a formula, it will be considered as string.
_________________ EasyXLS Team .NET and Java library to read and write Excel files Facebook X Reddit LinkedIn
|
Tue Sep 05, 2023 9:26 am |
|
|
|
Page 1 of 1
|
[ 6 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|