How do I format numbers into text (XlsIO)

The ChipFormat column retrieved from the MS SQL database and saved in varchar format (50)
When I try to export "Dim ChipFormat As String =" E11: E "& sheet.UsedRange.End.Row" and the column has initial 0, it is filtered out.
How do I export data from "CHIP NUMBER" as text?
If I have "01234567890" it is exported without initial 0 as "1234567890"

See attached code and excel file...






Attachment: chiplist_8542217a.zip

5 Replies 1 reply marked as answer

MC Mohan Chandran Syncfusion Team October 19, 2020 09:27 AM UTC

Hi Kjell, 
 
Greetings from Syncfusion support. 
 
Please refer the code snippet below to achieve your requirement. 
 
Code snippet: 
ExcelEngine excelEngine = new ExcelEngine(); 
IApplication application = excelEngine.Excel; 
IWorkbook workbook = application.Workbooks.Create(1); 
workbook.Version = ExcelVersion.Excel2016;  
IWorksheet srcSheet = workbook.Worksheets[0]; 
 
DataTable dt = new DataTable(); 
dt.Columns.Add("Data", typeof(string)); 
dt.Rows.Add("01234567890"); 
dt.Rows.Add("0123456780"); 
dt.Rows.Add("01234567899"); 
dt.Rows.Add("012345678989"); 
dt.Rows.Add("012345678"); 
 
srcSheet.ImportDataTable(dt,true, 1, 1, true); 
 
workbook.SaveAs("Output.xlsx"); 
workbook.Close(); 
 
Kindly try this and let us know whether it helps. 
 
Regards, 
Mohan. 
 



KE Kjell Ek October 19, 2020 10:28 AM UTC

I use ImportDataColumn....

sheet.ImportDataColumn(dt.Columns(3), True, 13, 5)
and if the data has an initial zero, it is not displayed, but it is displayed if it is at the end

How format column as Text or or how do i make the initial 0 appear?


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team October 20, 2020 11:39 AM UTC

Hi Kjell, 

Thanks for the update. 

We are able to reproduce the reported issue at our end and validating it currently. We will share the validation details on two business days, on October 22nd,2020. 

Regards, 
Keerthi. 



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team October 22, 2020 04:43 PM UTC

Hi Kjell, 

We appreciate your patience. 

We have confirmed the issue to Provide support to set preserve type option while importing data columns and logged a defect report. We will provide the fix for this issue on November 5th,2020. You can track the status of defect report through following feedback link. 


Regards, 
Keerthi. 



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team November 5, 2020 04:58 PM UTC

Hi Kjell, 

We appreciate your patience. 

We have Provided support to set preserve type option while importing data columns and generated patch in the version v18.3.0.35. We suggest you to use the following code snippet along with the below patch. 

Code Snippet: 

worksheet.ImportDataColumn(dt.Columns[0], true, 13, 5, true); 

The patch with fix to resolve the reported issue can be downloaded from the following link.  


Recommended approach - exe will perform automatic configuration       
   
Please find the patch setup from below location: 
       
Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment       
   
Please find the patch assemblies alone from below location:       
 
     
Assembly Version: 18.3.0.35 

Installation Directions :        
This patch should replace the files “Syncfusion.XlsIO.Base.dll” under the following folder.       
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.6       
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\18.3.0.35\precompiledassemblies\18.3.0.35\4.6    
       
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.       
       
Note :        
You can change how you receive bug fixes by navigating to the following link and updating your preferences.        
    
Disclaimer :   
Please note that we have created this patch for version 18.3.0.35 specifically to resolve the issues reported in forum 158836.      
              
If you have received other patches for the same version for other products, please apply all patches in the order received.       
      
This fix will be included in our release version 18.4 which will be rolled out by end of December 2020.   

Regards,     
Keerthi. 



Marked as answer
Loader.
Up arrow icon