Bug 144415 - CSV external data import field types doesn't affect cell format
Summary: CSV external data import field types doesn't affect cell format
Status: RESOLVED FIXED
Alias: None
Product: calligrasheets
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Calligra Sheets (KSpread) Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-19 11:05 UTC by Tais P. Hansen
Modified: 2007-08-01 17:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Examples csv-file (198 bytes, text/x-csv)
2007-04-19 11:06 UTC, Tais P. Hansen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tais P. Hansen 2007-04-19 11:05:36 UTC
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.
Comment 1 Tais P. Hansen 2007-04-19 11:06:23 UTC
Created attachment 20321 [details]
Examples csv-file
Comment 2 Stefan Nikolaus 2007-08-01 17:35:03 UTC
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();