小编SWa*_*SWa的帖子

如何使用VBA在指定的单元格位置将图片插入Excel

我正在将".jpg"文件添加到我的Excel工作表中,代码如下:

'Add picture to excel
xlApp.Cells(i, 20).Select
xlApp.ActiveSheet.Pictures.Insert(picPath).Select
'Calgulate new picture size
With xlApp.Selection.ShapeRange
    .LockAspectRatio = msoTrue
    .Width = 75
    .Height = 100
End With
'Resize and make printable
With xlApp.Selection
    .Placement = 1 'xlMoveAndSize
    '.Placement = 2 'xlMove
    '.Placement = 3 'xlFreeFloating
    .PrintObject = True
End With
Run Code Online (Sandbox Code Playgroud)

我不知道我做错了什么,但它没有插入到正确的单元格中,所以我应该怎么做才能将这张图片放入Excel中的指定单元格?

excel vba image insert

24
推荐指数
3
解决办法
19万
查看次数

Linq运行总计第一个值加到自身

我有以下计算客户帐户状态的运行总计,但是他的第一个值总是添加到自身,我不知道为什么 - 虽然我怀疑我错过了一些明显的东西:

    decimal? runningTotal = 0;
    IEnumerable<StatementModel> statement = sage.Repository<FDSSLTransactionHistory>()
        .Queryable()
        .Where(x => x.CustomerAccountNumber == sageAccount)
        .OrderBy(x=>x.UniqueReferenceNumber)
        .AsEnumerable()
        .Select(x => new StatementModel()
        {
            SLAccountId = x.CustomerAccountNumber,
            TransactionReference = x.TransactionReference,
            SecondReference = x.SecondReference,
            Currency = x.CurrencyCode,
            Value = x.GoodsValueInAccountCurrency,
            TransactionDate = x.TransactionDate,
            TransactionType = x.TransactionType,
            TransactionDescription = x.TransactionTypeName,
            Status = x.Status,
            RunningTotal = (runningTotal += x.GoodsValueInAccountCurrency)
        });
Run Code Online (Sandbox Code Playgroud)

哪个输出:

29/02/2012 00:00:00 154.80  309.60  
30/04/2012 00:00:00 242.40  552.00  
30/04/2012 00:00:00 242.40  794.40  
30/04/2012 00:00:00 117.60  912.00  
Run Code Online (Sandbox Code Playgroud)

309.60第一排的应该是简单154.80

我做错了什么?

编辑: …

c# linq

10
推荐指数
1
解决办法
319
查看次数

查看序列化时链接中断

我有以下作为填充局部视图的视图模型的一部分:

public string DownloadLink
{
    get
    {
        UrlHelper url = new UrlHelper(HttpContext.Current.Request.RequestContext);
        switch (this.Type)
        {
            case (int)DocumentTypes.WasteNote: { 

                return url.Action("PaperWork", "Jobs", new { JobId = this.DOCJobId }, HttpContext.Current.Request.IsSecureConnection ? "https" : "http" ); 
            }
            case (int)DocumentTypes.Contract:
            case (int)DocumentTypes.DestructionCert:
            case (int)DocumentTypes.Quote:
            default: { return url.Action("Download", "Documents", new { DocId = this.DocumentLinkId }, HttpContext.Current.Request.IsSecureConnection ? "https" : "http"); }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

因此在视图中调用:

@model  IEnumerable<Document>
@using CustomerDashboard.ViewModels;
@using CustomerDashboard.Utilities;
@{ Layout = null; }
    @foreach (Document doc in Model)
    {
        <li>
            <a …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc asp.net-mvc-5

6
推荐指数
1
解决办法
240
查看次数

Backbone,requireJS,Googlemaps - 地图未显示

我在浏览器页面上显示谷歌地图时遇到问题,我正在使用RequireJS和Backbone,显然遗漏了一些简单的东西(我刚开始使用骨干网),但地图永远不会在页面上呈现.没有错误,.map属性看起来像谷歌地图对象.

得到一些指示真的很好

以下是我可以做到的简化,但展示了行为:

标记摘录:

<style>
#mapCanvas img { width:auto, max-width: auto; display:inline; }
#mapCanvas {height:600px;}
</style>

<div class="span8">
    <div id="mapCanvas">

    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

码:

requirejs.config({
  baseUrl: '../resources/js',
  paths: {
        jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min',
        jqueryui: 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min',
        datatables: 'http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min',
        gmaps: 'http://maps.google.com/maps/api/js?sensor=false',
        backbone : 'libs/backbone.min',
        underscore: 'libs/underscore.min'
    },
  shim: {
    gmaps: {
        deps: ['jquery','async!http://maps.google.com/maps/api/js?sensor=false'],
        exports: 'google'
    },
    underscore: {
        exports: '_'
    },
    backbone: {
        deps: ['underscore', 'jquery'],
        exports: 'Backbone'
    }
  }
});


 require(["domReady!","jquery","underscore","backbone", "gmaps"], function(doc, $, _, Backbone, google) {

    var siteMarkers = Backbone.View.extend({
        el: "#mapCanvas", …
Run Code Online (Sandbox Code Playgroud)

google-maps requirejs backbone.js

2
推荐指数
1
解决办法
1403
查看次数

DropDownListFor没有绑定值

我有以下ViewModel

    public class ContactAddViewModel
    {
        string _title;
        public ContactAddViewModel()
        {
            var titles = new List<SelectListItem>()
            {
                new SelectListItem() { Value = "Mr", Text= "Mr" },
                new SelectListItem() { Value= "Miss", Text="Miss" },
                new SelectListItem() { Value = "Mrs", Text= "Mrs" },
                new SelectListItem() { Value = "Ms", Text = "Ms" },
                new SelectListItem() { Value = "Dr", Text = "Dr" }
            };

            Titles = titles;
        }

        [Required]
        [Display(Name = "Title")]
        public string Title { get; set; }
        public IEnumerable<SelectListItem> Titles …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-mvc-5

0
推荐指数
1
解决办法
1309
查看次数