Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Dec 07, 2017 5:05 am

Hi

I download "Free Spire.XLS for .NET Version:7.9". After I export a C# gridview context into excel, the .xls file can be generated, but when I open this file, I get warning message as:

"We found a problem with some context in [filename.xls]. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click yes. "

How can I get rid of this warning message?

Thank you!
Michelle

MichelleChen
 
Posts: 11
Joined: Mon Dec 04, 2017 5:56 pm

Thu Dec 07, 2017 7:22 am

Hello,

Thanks for your inquiry. Please use the most new verion(Spire.XLS Pack Hotfix Version:7.12.125) and try again. If the issue still exists, please share us with your full code and data from gridview.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Dec 07, 2017 5:22 pm

Hi Simon,

Thank you for reply my post. I downloaded Spire.XLS for .NET Standard Edition(Hotfix) Version:7.12.57 .
I still got the same error.

I found this hot fix only include three files: Spire.License.dll, Spire.XLS, Spire.XLS.dll,. My code is using Spire.DataExport.XLS. That is probably this hot fix package does not solve my problem.

Thanks,
Michelle

MichelleChen
 
Posts: 11
Joined: Mon Dec 04, 2017 5:56 pm

Fri Dec 08, 2017 6:08 am

Hello Michelle,

Thanks for your feedback. I thought you were using Spire.Xls. But with Spire.DataExport, I still can't reproduce the issue. Please share us with your full code, result .xls file and MS Excel version information for further investigation. Below is the code snippet I am using.
Code: Select all
        //load
        private void button1_Click(object sender, EventArgs e)
        {
            string connectText = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb";
            OleDbConnection oleDbConnection1 = new OleDbConnection(connectText);
            OleDbCommand oleDbCommand1 = new OleDbCommand("select * from Report", oleDbConnection1);
            DataTable dt = new DataTable();
            using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand1))
            {
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }           
        }

        //save
        private void button2_Click(object sender, EventArgs e)
        {
            Spire.DataExport.XLS.CellExport cellExport = new Spire.DataExport.XLS.CellExport();
            Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet();
            worksheet1.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
            worksheet1.DataTable = this.dataGridView1.DataSource as DataTable;
            worksheet1.StartDataCol = ((System.Byte)(0));
            cellExport.Sheets.Add(worksheet1);
            cellExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            cellExport.SaveToFile("20171208.xls");
        }


Best regards,
Simon
E-iceblue support team
Last edited by Simon.yang on Tue Dec 12, 2017 8:17 am, edited 1 time in total.
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Dec 12, 2017 8:01 am

Hello,

Hope you are doing fine.
How is the issue going? Please give us some feedback at your convenience.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Dec 12, 2017 10:04 pm

Hi Mr. Yang,

I copied my code as below. Could you let me know why I got the waring message when I open the created excel? Thank you!

// Create a DataTable
DataTable dt = new DataTable("MyDataTable");

dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Price", typeof(decimal));

DataRow row1 = dt.NewRow();
row1["Id"] = 1;
row1["Date"] = new DateTime(2017, 12, 1);
row1["Name"] = "Michelle";
row1["Price"] = 122.12;
dt.Rows.Add(row1);

DataRow row2 = dt.NewRow();
row2["Id"] = 2;
row2["Date"] = new DateTime(2017, 12, 15);
row2["Name"] = "Chen";
row2["Price"] = 15000.45;
dt.Rows.Add(row2);

// Create instance of CellEXport
CellExport myCellExport = new CellExport();

WorkSheet sheet = new WorkSheet();
sheet.DataExported = false;
sheet.SheetName = "ABC";
sheet.ItemType = CellItemType.Row;
sheet.AutoFitColWidth = true;
this._cellExport.Sheets.Add(sheet);


// Add Excel Header row
Cell cell1 = new Cell();
cell1.Row = 1;
cell1.Column = 1;
cell1.Value = "Id";
sheet.Cells.Add(cell1);

Cell cell2 = new Cell();
cell2.Row = 1;
cell2.Column = 2;
cell2.Value = "Date";
sheet.Cells.Add(cell2);

Cell cell3 = new Cell();
cell3.Row = 1;
cell3.Column = 3;
cell3.Value = "Name";
sheet.Cells.Add(cell3);

Cell cell4 = new Cell();
cell4.Row = 1;
cell4.Column = 4;
cell4.Value = "Price";
sheet.Cells.Add(cell4);

// Add Excel content rows
int currentRow = 1;
foreach (DataRow dr in dt.Rows)
{
currentRow++;
object[] a = dr.ItemArray;

for (int i = 0; i < dt.Columns.Count; i++)
{
Cell cell = new Cell();
cell.Row = currentRow;
cell.Column = i+1;
string Michelle = a[i].GetType().ToString();
string Michelle_DateTime = typeof(DateTime).ToString();
string Michelle_decimal = typeof(decimal).ToString();
if (typeof(DateTime) == a[i].GetType())
{
cell.Value = Convert.ToDateTime(a[i]).ToString();
}
else if (typeof(Int16) == a[i].GetType() || typeof(Int32) == a[i].GetType())
{
cell.CellType = CellType.Numeric;
cell.NumericFormat = String.Empty;
cell.Value = a[i];
}
else if (typeof(double) == a[i].GetType() || typeof(decimal) == a[i].GetType())
{
cell.CellType = CellType.Numeric;
cell.NumericFormat = "$#,###,###,##0.00";
cell.Value = a[i];
}
else if (typeof(byte[]) == a[i].GetType())
{
cell.Value = this.ByteToString((byte[])a[i]);
}
else
{
cell.Value = a[i].ToString();
}

sheet.Cells.Add(cell);
}
}
myCellExport.Sheets.Add(sheet);
myCellExport.SaveToFile("C:\\Temp2\\MyTest.xls");

MichelleChen
 
Posts: 11
Joined: Mon Dec 04, 2017 5:56 pm

Wed Dec 13, 2017 6:32 am

Hello,

Thanks for your inquiry. Please use Spire.XLS Pack Hotfix Version:7.12.125 to accomplish your task. Below is the code snippet for your reference.
Code: Select all
            // Create a DataTable
            DataTable dt = new DataTable("MyDataTable");

            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Date", typeof(DateTime));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Price", typeof(decimal));

            DataRow row1 = dt.NewRow();
            row1["Id"] = 1;
            row1["Date"] = new DateTime(2017, 12, 1);
            row1["Name"] = "Michelle";
            row1["Price"] = 122.12;
            dt.Rows.Add(row1);

            DataRow row2 = dt.NewRow();
            row2["Id"] = 2;
            row2["Date"] = new DateTime(2017, 12, 15);
            row2["Name"] = "Chen";
            row2["Price"] = 15000.45;
            dt.Rows.Add(row2);
           
            Workbook book = new Workbook();
            book.Worksheets.Clear();
            Worksheet sheet = book.Worksheets.Add("ABC");

            // Format cells and add content
            int currentRow = 0;
            foreach (DataRow dr in dt.Rows)
            {
                object[] a = dr.ItemArray;

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    if (typeof(DateTime) == a[i].GetType())
                    {
                        sheet.Rows[currentRow].Cells[i].Value = Convert.ToDateTime(a[i]).ToString();
                    }
                    else if (typeof(Int16) == a[i].GetType() || typeof(Int32) == a[i].GetType())
                    {
                        sheet.Rows[currentRow].Cells[i].Value = a[i].ToString();           
                    }
                    else if (typeof(double) == a[i].GetType() || typeof(decimal) == a[i].GetType())
                    {
                        sheet.Rows[currentRow].Cells[i].NumberFormat = "$#,###,###,##0.00";
                        sheet.Rows[currentRow].Cells[i].Value = a[i].ToString();
                    }
                    else if (typeof(byte[]) == a[i].GetType())
                    {
                        //sheet.Rows[currentRow].Cells[i].Value = this.ByteToString((byte[])a[i]);
                    }
                    else
                    {
                        sheet.Rows[currentRow].Cells[i].Value = a[i].ToString();
                    }
                }
                currentRow++;
            }
            book.SaveToFile("result.xls",ExcelVersion.Version97to2003);


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Dec 13, 2017 9:15 pm

Hi Simon,

Thanks for the quick response.

I downloaded Spire.XLS Pack Hotfix Version:7.12.125.

Now the problem is that the License.dll in this package is 1.3.6.40(I am using the dll in NET4.0 folder), but my project also needs to create Spire.DataExport.XLS.CellExpor object which I think it needs Spire.License, Version=1.3.5.40. So now I got run time error as:

Could not load file or assembly 'Spire.License, Version=1.3.5.40, Culture=neutral, PublicKeyToken=b1144360237c8b3f' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Spire.License, Version=1.3.5.40, Culture=neutral, PublicKeyToken=b1144360237c8b3f' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


So, do you think I need to use an updated version of Spire.DataExport.XLS.CellExport? Thank you!

MichelleChen
 
Posts: 11
Joined: Mon Dec 04, 2017 5:56 pm

Thu Dec 14, 2017 1:58 am

Hello,

Thanks for your reply. Spire.DataExport and Spire.Xls are two independent products and they are not compatible for each other. You need to use the corresponding dlls from Spire.Office Platinum (DLL Only) Version:2.16.23. Please download it and try again.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Dec 14, 2017 7:33 am

Hi Simon,

Thanks for your help.

Now I realized that my original code used Spire.DataExport, and the code you just provided to me is using Spire.Xls.

But the excel generated through Spire.Xls has a "evaluation warning" sheet. I do not want this waring sheet. Do you provide a free Spire.Xls which out "evaluation warning" sheet?

Thanks,
Michelle

MichelleChen
 
Posts: 11
Joined: Mon Dec 04, 2017 5:56 pm

Thu Dec 14, 2017 8:32 am

Hello Michelle,

Thanks for your inquiry. We do have free version, but I find it can not full fill your needs. Hence, you need to use the commercial version instead. To help you remove the warning message, our sales has sent an one-month temporary license to your registered email. Please check your email and refer to the below documentation to apply the license.
https://www.e-iceblue.com/Tutorials/Lic ... html#Apply

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Dec 19, 2017 7:33 am

Hello,

Greeting from E-iceblue.
Is the license helpful to you?
Your feedback will be greatly appreciated.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Feb 08, 2018 8:00 pm

Hello Simon,

Yes, the license helps. Spire has worked well for us for more than two months.

I am wondering without buying a commercial product from you, is there any expiration for the license you provided? What other limitations for these free version of Spire.XLS.dll and Spire.License.dll. By that I mean: Are there limited number of users, workbooks/sheets/rows/columns limitation that will be enforced without purchasing your commercial product?

I am asking this because in order to get rid of the warning message (see the red message in my original post), it seems as though we need to Spire.XLS.dll and Spire.License.dll, rather than being able to use Spire.DataExport.

Thanks,
Michelle

MichelleChen
 
Posts: 11
Joined: Mon Dec 04, 2017 5:56 pm

Fri Feb 09, 2018 9:37 am

Hello,

Thanks for your response. The license we sent to you is temporary, which is only valid for one month, after it expires, the extra “Evaluation Sheet” will appear again in the result file generated by the commercial version, the free version won't bring you evaluation sheet, but is limited to 5 sheets per workbook and 200 rows per sheet when creating .xls files. Plus, the free product is not always up to date and may fail to support some specific functionalities.
In addition, Spire.XLS is the best choice for your specifc requirments. Currently, Spire.DataExport has problems in accomplishing this task.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Feb 09, 2018 9:26 pm

HI Gary,

Thanks for your reply. Can you please provide pricing on a license for this product that is not temporary.

Regards,
Michelle

MichelleChen
 
Posts: 11
Joined: Mon Dec 04, 2017 5:56 pm

Return to Spire.XLS