Version: 1.6.2 (using KDE KDE 3.5.6) Installed from: Compiled From Sources Compiler: gcc (GCC) 3.4.6 OS: Linux When inserting data from a csv-file in a spreadsheet by using Insert > External Data > From Text File, setting column format doesn't affect resulting cell format. All cells are still set to "Generic". Example csv-file attached.
Created attachment 20321 [details] Examples csv-file
SVN commit 695194 by nikolaus: Commands CSV Data Insertion. Initial implementation. Moved the logic into its own command and fix the issue, that the column data types were ignored. BUGS: 95552, 144415 M +1 -0 CMakeLists.txt A commands/CSVDataCommand.cpp [License: LGPL (v2+)] A commands/CSVDataCommand.h [License: LGPL (v2+)] M +27 -18 dialogs/CSVDialog.cpp --- trunk/koffice/kspread/CMakeLists.txt #695193:695194 @@ -41,6 +41,7 @@ commands/AutoFormatCommand.cpp commands/CommentCommand.cpp commands/ConditionCommand.cpp + commands/CSVDataCommand.cpp commands/DataManipulators.cpp commands/DefinePrintRangeCommand.cpp commands/DeleteCommand.cpp --- trunk/koffice/kspread/dialogs/CSVDialog.cpp #695193:695194 @@ -41,7 +41,7 @@ #include "Sheet.h" #include "View.h" -#include "commands/DataManipulators.h" +#include "commands/CSVDataCommand.h" using namespace KSpread; @@ -162,24 +162,33 @@ else m_targetRect.setBottom( m_targetRect.top() + numRows - 1 ); - Value val( Value::Array ); - for (int row = 0; row < numRows; ++row) - for (int col = 0; col < numCols; ++col) - val.setElement (col, row, Value(text(row, col))); + QList<KoCsvImportDialog::DataType> dataTypes; + Value value(Value::Array); + for (int row = 0; row < numRows; ++row) + { + for (int col = 0; col < numCols; ++col) + { + value.setElement(col, row, Value(text(row, col))); + if (row == 0) + dataTypes.insert(col, dataType(col)); + } + } - DataManipulator *manipulator = new DataManipulator; - if ( m_mode == Clipboard ) - manipulator->setText( i18n( "Inserting From Clipboard" ) ); - else if ( m_mode == File ) - manipulator->setText( i18n( "Inserting Text File" ) ); - else - manipulator->setText( i18n( "Text to Columns" ) ); - manipulator->setSheet (sheet); - manipulator->setParsing (true); - manipulator->setFormat (Format::Generic); - manipulator->setValue (val); - manipulator->add (m_targetRect); - manipulator->execute (); + CSVDataCommand* command = new CSVDataCommand(); + if (m_mode == Clipboard) + command->setText(i18n("Inserting From Clipboard")); + else if (m_mode == File) + command->setText(i18n("Inserting Text File")); + else + command->setText(i18n("Text to Columns")); + command->setSheet(sheet); + command->setValue(value); + command->setColumnDataTypes(dataTypes); + command->setDecimalSymbol(decimalSymbol()); + command->setThousandsSeparator(thousandsSeparator()); + command->add(m_targetRect); + if (!command->execute()) + delete command; m_pView->slotUpdateView( sheet ); KoCsvImportDialog::accept();