Hi Team,
we are using aspose cells 7.0.4.jar.
we found one thing in our one of column having the data like 00000 this will be converted to 0 and suppress the zeros in data sheet.
please find the attached source and csv file.
Thanks,
Kumar.
Hi,
hi Team,
Thanks for giving replay.
please open the csv in notepad and check it.
we also applied the format for column as text . but this will suppress the zeros.
but we need to display the 0000 instead of 0 in column.
please find the required output for csv file and source code.
Hi,
Hi Team ,
thanks for giving solution.
this working for csv file.
we have a case where data coming from database table.
using light cells data provider we are generating the excel.
i am using this one "writeWorkbook.getSettings().setConvertNumericData(false);"
but this is not resolve the issue.
thanks,
kumar.
Hi Kumar,
Hi Team,
we are generating the large excel from clob using light cell data provider.
to test the issue we creating csv file from clob.
please find the code for 2007 excel generation.
thanks,
kumar.
Hi,
Hi Team,
any update on this?
Thanks,
Kumar.
Hi,
Spring Festival holidays, he will re-join us in the next week. Hopefully, we could update you on your issue in the next week.
Hi Team,
Thanks for giving response.
public void putValue(java.lang.String stringValue, boolean isConverted) |
-
Puts a string value into the cell and converts the value to other data type if appropriate. - Parameters:
-
stringValue
- Input value -
isConverted
- True: converted to other data type if appropriate.
according to doc putvalue method convert the string to specified data type.
- in my case i will apply the format for columns at beginning. later it will be converted to specified format.
- by using putvalue method. if i did not use this one, format for numbers and date will lost.
- in my case the format for column will be text for data lost columns. so the source and destination format will be same. even though truncate will happened.
2.conversion will take time is there any other eefecient way to set or convert the data to specified data type.
currently we are applying the format column wise before data dumping.After lightcells's converting the data to specified data type.
- Thanks,
- eistechnologies.
Hi,
For Cell.putValue(value, true), our component will try many number formattings to check whether one can be applied to given value and parse it to proper value type if one available number formatting be found. So the process is time consumed.
For your situation, if the data type for one column(or most of the data of one column) is known for you, it would be much better for performance for you to convert the data to proper value type by yourself and then set to a cell.
Sample code for LightCellsDataProvider:
Java
String[] columnFormatString = …;
java.text.Format columnFormat = …;
…
public void startCell(Cell cell)
{
try{
if(cellValue.hasMoreTokens())
{
String strVal = cellValue.nextToken().trim();
if(strVal.equals(""))
{
return;
}
if(columnFormat[cell.getColumn()] != null)
{
try
{
Object v = columnFormat[cell.getColumn()].parseObject(strVal);
cell.putValue(v);
Style style = cell.getStyle();
style.setCustom(columnFormatString[cell.getColumn()]);
cell.setStyle(style);
return;
}
catch(Excepton e)
{
}
}
if(strVal.charAt(0) == ‘0’)
{
cell.putValue(strVal);
}
else
{
cell.putValue(strVal,true);
}
}
}
catch(Exception e)
{
logger.warning(e.getMessage());
}
}
Hi Team,
I am totally confused on this.
Object v = columnFormat[cell.getColumn()].parseObject(strVal);
cell.putValue(v);
Style style = cell.getStyle();
style.setCustom(columnFormatString[cell.getColumn()]);
cell.setStyle(style);
give some clarification on this
case: Generating large excel having formats like date , text and number using LightCells
which approach is taking less memory and less generating time
1. Applying format to whole Column is efficient or Cell wise.
2.Applying style to column is efficient or manually convert string to required data type and set to cell is efficient.
Thanks
kumar.
Hi,
Please see the following answers to your questions.
1. Applying format to whole Column is efficient or Cell wise
If most of cells in one column can use the same style, applying format to the whole column is much more efficient than applying to every cell one by one.
2. Applying style to column is efficient or manually convert string to required data type and set to cell is efficient
If you use cell.putValue(value, true) and the given value needs to be parsed as other type, we also need to reset the cell’s style according with the parsed formatting even if you have applied style for the whole column. So for setting styles there is no many difference for two ways. However, if most of your data of one column can use the same pattern to parse, it will be much more efficient for you to convert string to required data type by yourself than use cell.setValue(value, true).
So, for your situation, if you can apply the specified number formatting to one whole column, the more efficient code should be like:
Java
//set columns’ style before processing cells data
StyleFlag f = new StyleFlag();
f.setNumberFormat(true);
for(…)
{
Column column = …;
Style style = column.getStyle();
style.setCustom(columnFormatString[column.getIndex()]);
column.applyStyle(style, f);
}
…
In implementation of LightCellsDataProvider:
public void startCell(Cell cell)
{
if(…)
{
…
try
{
Object v = columnFormat[cell.getColumn()].parseObject(strVal);
cell.putValue(v);
}
…
}
}