Exporting Data to Excel
How would I go about coding a script that would allow me to take data from a gyroscope and put it into either a data table exportable to Excel or directly onto Excel each frame? Also I don't have the money for Uni-Excel. I've tried using a slightly altered version of http://stackoverflow.com/questions/23041021/how-to-write-some-data-to-excel-file-xlsx but I am unable to reference the Microsoft.Office namespace even though I have Microsoft.Office.Interop.Excel added through VS 2015's add reference option. Any ideas? Thanks,
Answer by Don-Tako · Jul 25, 2017 at 10:07 PM
IF your data don't need format like colors, font styles, etc.. use CSV instead
IEnumerator CrearArchivoCSV(string nombreArchivo)
{
string ruta = Application.persistentDataPath + "/" + nombreArchivo + ".csv";
//El archivo existe? lo BORRAMOS
if (File.Exists(ruta))
{
File.Delete(ruta);
}
//Crear el archivo
var sr = File.CreateText(ruta);
string datosCSV = "valor1,valor2,valor3,valor4" + System.Enviroment.NewLine;
datosCSV += "valor1,valor2,valor3,valor4" + System.Enviroment.NewLine;
datosCSV += "valor1,valor2,valor3,valor4" + System.Enviroment.NewLine;
datosCSV += "valor1,valor2,valor3,valor4" + System.Enviroment.NewLine;
datosCSV += "valor1,valor2,valor3,valor4";
sr.WriteLine(datosCSV);
//Dejar como sólo de lectura
FileInfo fInfo = new FileInfo(ruta);
fInfo.IsReadOnly = true;
//Cerrar
sr.Close();
yield return new WaitForSeconds(0.5f);//Esperamos para estar seguros que escriba el archivo
//Abrimos archivo recien creado
Application.OpenURL(ruta);
}
Hey @Don-Tako Hey @silverxah
Where we have to place this code? Is it below at the "xxxxxxxx" position?
using UnityEngine;
using System.Collections;
public class ExampleClass : $$anonymous$$onoBehaviour
{
.....my variables
xxxxxxxxxx
}
Answer by MyUnitydream · Sep 12, 2018 at 05:16 AM
you can use Uni-Excel Package for Read, Write, and edit excel files
Answer by alphadogware · Nov 05, 2019 at 10:07 PM
I am interested in this, but what build formats does it support?
Your answer
Follow this Question
Related Questions
Open C# Project Opens Windows Explorer 0 Answers
My animation is working but the character won't move. 2 Answers
Unity 5+ compatibility with VS2012 - ? 0 Answers
Missing MasterServer.exe 0 Answers