Hi all,
I meet 1 problem with MVC4 export using EPPlus.
I have 1 data in database as below:
[Code]
<strong>This is demo data <br />
<img alt="" src="/Images/images/Koala.jpg" style="height:150px; width:200px" /></strong>
[/Code]
Now i want to export this data to excel include Image follow above path.
How to export to excel include image?
Hi all,
I meet 1 problem with MVC4 export using EPPlus.
I have 1 data in database as below:
[Code]
<strong>This is demo data <br />
<img alt="" src="/Images/images/Koala.jpg" style="height:150px; width:200px" /></strong>
[/Code]
Now i want to export this data to excel include Image follow above path.
How to export to excel include image?
Are you getting any error? Here are some links that show how to export images using EPPlus:
Hi IbrahimIslam,
Thank you very much for your great support.
However, i want to se how to export data from database to excel include picture.
My column in database contain below data:
<strong>This is demo data <br />
<img alt="" src="/Images/images/Koala.jpg" style="height:150px; width:200px" /></strong>
How to export together above content to 1 row on excel sheet.
Please support!
Hi IbrahimIslam,
Thank you very much!
I want to export above HTML as Text and text inside, however how to display image inside cell of excel.
How to do it?Please support me.
Hi IbrahimIslam,
Thank you very much!
I want to export above HTML as Text and text inside, however how to display image inside cell of excel.
How to do it?Please support me.
Thank you for your support!<br>
This forum don't have space to upload picture.<br>
I want to show you my out put.<br>
After that you are easy to support.
My code to export
[Code]
public ActionResult Eri_Cover_Sheet_PE1(string Eri_No)
{
FileInfo templateFile = new FileInfo(this.Request.PhysicalApplicationPath + "Upload Template/ECN_Cover_Sheet_PE1.xlsx");
Ecn_Cover_PE1s = _db.Database.SqlQuery<Models.Eri_PE1_Cover>("exec Pro_Get_ERI_Cover_Report_PE1 '" + Eri_No + "'").ToList();
using (ExcelPackage package = new ExcelPackage(templateFile))
{
picture.From.ColumnOff = ExcelHelper.Pixel2MTU(2); //Two pixel space for better alignment
picture.From.RowOff = ExcelHelper.Pixel2MTU(2);//Two pixel space for better alignment
picture.SetSize(100, 100);
When i show on View, i can see structure. However i want to export excel save structure display on View.
How to export above data keep structure of HTML above.
Member
2 Points
46 Posts
How to export html table in sql database to excel.
Jan 11, 2015 09:15 PM|dophuong_cs|LINK
I meet 1 problem with MVC4 export using EPPlus.
I have 1 data in database as below:
[Code]
<strong>This is demo data <br />
<img alt="" src="/Images/images/Koala.jpg" style="height:150px; width:200px" /></strong>
[/Code]
Now i want to export this data to excel include Image follow above path.
How to export to excel include image?
Participant
1231 Points
375 Posts
Re: How to export html table in sql database to excel.
Jan 12, 2015 02:03 AM|IbrahimIslam|LINK
Are you getting any error? Here are some links that show how to export images using EPPlus:
stackoverflow.com/questions/13174380/placing-image-inside-excel-file
stackoverflow.com/questions/11588704/adding-images-into-excel-using-epplus
Member
2 Points
46 Posts
Re: How to export html table in sql database to excel.
Jan 12, 2015 02:15 AM|dophuong_cs|LINK
Thank you very much for your great support.
However, i want to se how to export data from database to excel include picture.
My column in database contain below data:
<strong>This is demo data <br />
<img alt="" src="/Images/images/Koala.jpg" style="height:150px; width:200px" /></strong>
How to export together above content to 1 row on excel sheet.
Please support!
Participant
1231 Points
375 Posts
Re: How to export html table in sql database to excel.
Jan 12, 2015 04:23 AM|IbrahimIslam|LINK
Do you want to export the above whole HTML as text or the image and text inside?
Member
2 Points
46 Posts
Re: How to export html table in sql database to excel.
Jan 12, 2015 05:07 AM|dophuong_cs|LINK
Thank you very much!
I want to export above HTML as Text and text inside, however how to display image inside cell of excel.
How to do it?Please support me.
Participant
1231 Points
375 Posts
Re: How to export html table in sql database to excel.
Jan 12, 2015 07:44 AM|IbrahimIslam|LINK
Paste in your existing code and you can try some tutorials as well: http://zeeshanumardotnet.blogspot.com/2011/06/creating-reports-in-excel-2007-using.html
Member
2 Points
46 Posts
Re: How to export html table in sql database to excel.
Jan 12, 2015 09:07 PM|dophuong_cs|LINK
Thank you for your support!<br>
This forum don't have space to upload picture.<br>
I want to show you my out put.<br>
After that you are easy to support.
My code to export
[Code]
public ActionResult Eri_Cover_Sheet_PE1(string Eri_No)
{
FileInfo templateFile = new FileInfo(this.Request.PhysicalApplicationPath + "Upload Template/ECN_Cover_Sheet_PE1.xlsx");
Ecn_Cover_PE1s = _db.Database.SqlQuery<Models.Eri_PE1_Cover>("exec Pro_Get_ERI_Cover_Report_PE1 '" + Eri_No + "'").ToList();
using (ExcelPackage package = new ExcelPackage(templateFile))
{
// Ecn_Cover_Sheet for PE1
ExcelWorksheet worksheet = package.Workbook.Worksheets["(ECN COVER)"];
string file = this.Request.PhysicalApplicationPath + "Images/images/Koala.jpg";
Bitmap image = new Bitmap(file);
ExcelPicture picture = null;
picture = worksheet.Drawings.AddPicture("pic" , image);
picture.From.Column = 1;
picture.From.Row = 8;
picture.From.ColumnOff = ExcelHelper.Pixel2MTU(2); //Two pixel space for better alignment
picture.From.RowOff = ExcelHelper.Pixel2MTU(2);//Two pixel space for better alignment
picture.SetSize(100, 100);
worksheet.Cells[4, 2].Value = Ecn_Cover_PE1s[0].Eri_No;
worksheet.Cells[8, 1].Value = Ecn_Cover_PE1s[0].Eri_Content;
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=" + Eri_No + "_" + DateTime.Today.ToString("yyyymmdd") + ".xlsx");
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.BinaryWrite(package.GetAsByteArray());
Response.End();
return null;
}
}
[/Code]
My data of column in database store as below:
[Code]
<ol>
<li style="text-align: center"><u><em><strong><span style="color:#000000"><span class="marker"><span style="background-color:#ff8c00">fdasfasdfdasfdsa</span></span></span></strong></em></u></li>
<li style="text-align: center"><u><em><strong><span style="color:#000000"><span class="marker"><span style="background-color:#ff8c00">fsdafafdsafds</span></span></span></strong></em></u><br />
</li>
</ol>
<img alt="" src="/Images/images/Koala.jpg" style="float:left; height:150px; width:200px" /><br />
<br />
<br />
<br />
<br />
<br />
<br />
<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td>fasd</td>
<td>fddfas</td>
</tr>
<tr>
<td>fdafd</td>
<td>fdas</td>
</tr>
<tr>
<td>fdas</td>
<td>fdas</td>
</tr>
</tbody>
</table>
<br />
[/Code]
When i show on View, i can see structure. However i want to export excel save structure display on View.
How to export above data keep structure of HTML above.