![]() Please bookmark this page and share it with your friends. I have kept the image file in the same project directory so that it can be used by excel API and load it in the proper location in Excel.įinally Image will be entered at required location successfully,ĭo you have any comments or ideas or any better suggestions to share? IPicture picture = drawing.CreatePicture(anchor, pictureIndex) IClientAnchor anchor = helper.CreateClientAnchor() ![]() IDrawing drawing = excelSheet.CreateDrawingPatriarch() ICreationHelper helper = workbook.GetCreationHelper() Int pictureIndex = workbook.AddPicture(data, PictureType.JPEG) Row.CreateCell(cellIndex).SetCellValue(dsrow.ToString()) īyte data = File.ReadAllBytes("Read-write-excel-npoi.jpg") Row.CreateCell(columnIndex).SetCellValue(column.ColumnName) ISheet excelSheet = workbook.CreateSheet("TestSheet1") įoreach ( column in table.Columns) Using (var fs = new FileStream("Result.xlsx", FileMode.OpenOrCreate, FileAccess.Write)) Datatable is most easy way to deal with complex datatypes for easy reading and formatting.ĭataTable table = (DataTable)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(persons), (typeof(DataTable))) Lets converts our object data to Datatable for a simplified logic. # djangocms_pic/templates/pic_plugin.New UserDetails() , Image = models.ImageField(upload_to = CMSPlugin.get_media_path) Response is empty, also doesn't appear to be any JavaScript errors:Įdit 2: This replacement plugin works fine, don't know how: # djangocms_pic/cms_plugins.pyįrom cms.plugin_base import CMSPluginBase The image was stored to S3 and a CMSPlugin was created (but not a Picture): P.image.save(name='test.png', content=df)Īny ideas about what I'm doing wrong would be greatly appreciated, I'm stuck.Įdit 1: Thanks for the reply, mkoistinen, trying to get you more info but I'm honestly a little confused about how the pieces fit together so I just took screenshots.įorm in error state for a split second (I've tried to click that "Share this traceback." button without success): P = Picture(language=u'en', plugin_type=u'PicturePlugin', level=0, lft=1, rght=2, tree_id=3, placeholder=ph) THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGEĪlso, I can programmatically create a Picture plugin and it works fine: df = File(f) We use S3 as our media backend on Heroku, so set that upĭEFAULT_FILE_STORAGE = '3BotoStorage' The following are what I perceive to be the relevant settings: ''' The image is successfully uploaded to S3, and the plugin is created in the CMS but shows as. User-Agent: Mozilla/5.0 (Windows NT 6.1 WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/.153 Safari/537.36Ĭontent-Type: multipart/form-data boundary=-WebKitFormBoundaryegTMPxZL74WiukrgĬookie: django_language=en sessionid=wj7ayeia7rwggpxecatspe7lw5i12345 csrftoken=Pf342snoku6cdoRD6b9FCtxfqVQ12345 POST /en/admin/cms/page/edit-plugin/3/ HTTP/1.1Īccept: text/html,application/xhtml+xml,application/xml q=0.9,image/webp, / q=0.8 Currently the only media consists of Django CMS Picture plugins (which use a standard ImageField) and Aldryn Blog posts (which use a FilerImageField and easy_thumbnails).Īdding an image to blog posts via Django Filer works great, but adding an image when creating a Django CMS Picture plugin fails with a 500 error: Media will be served from S3 via Django Storages and Boto. I'm trying to deploy a Django CMS project to Heroku.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |