- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Project 中的 VBA 脚本将一些任务从 MS Project 导出到 Excel。到目前为止,我能够毫无问题地导出我想要的数据,并且它在 Excel 中打开得很好。我现在要做的是将 Excel 中的数据复制到类似于 Project 中的甘特图。我知道我知道,当我在 Project 中已经有了甘特图时,为了在 Excel 中获得甘特图而经历这一切有什么意义?除其他事项外,正在制作此 Excel 甘特图,以便没有 MS Project 的每个人都可以在没有 MS Project 的情况下查看计划任务。
所以到目前为止我尝试过的(因为 excel 没有内置的甘特图制作工具)是在电子表格上制作图表,为单元格着色以模仿甘特图。我的两个主要问题:
1. 我不知道如何为每个特定任务添加偏移量,具体取决于它从哪一天开始
2.我不知道如何为正确数量的单元格着色(现在它以 7 的倍数或一周一次的方式着色单元格,而不是直到特定的日期。
Sub ExportToExcel()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim proj As Project
Dim t As Task
Dim pj As Project
Dim i As Integer
Set pj = ActiveProject
Set xlApp = New Excel.Application
xlApp.Visible = True
AppActivate "Excel"
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Cells(1, 1).Value = "Project Name"
xlSheet.Cells(1, 2).Value = pj.Name
xlSheet.Cells(2, 1).Value = "Project Title"
xlSheet.Cells(2, 2).Value = pj.Title
xlSheet.Cells(4, 1).Value = "Task ID"
xlSheet.Cells(4, 2).Value = "Task Name"
xlSheet.Cells(4, 3).Value = "Task Start"
xlSheet.Cells(4, 4).Value = "Task Finish"
For Each t In pj.Tasks
xlSheet.Cells(t.ID + 4, 1).Value = t.ID
xlSheet.Cells(t.ID + 4, 2).Value = t.Name
xlSheet.Cells(t.ID + 4, 3).Value = t.Start
xlSheet.Cells(t.ID + 4, 4).Value = t.Finish
Dim x As Integer
'x is the duration of task in days(i.e. half a day long task is 0.5)
x = t.Finish - t.Start
'Loop to add day of week headers and color cells to mimic Gantt chart
For i = 0 To x
xlSheet.Cells(4, (7 * i) + 5).Value = "S"
xlSheet.Cells(4, (7 * i) + 6).Value = "M"
xlSheet.Cells(4, (7 * i) + 7).Value = "T"
xlSheet.Cells(4, (7 * i) + 8).Value = "W"
xlSheet.Cells(4, (7 * i) + 9).Value = "T"
xlSheet.Cells(4, (7 * i) + 10).Value = "F"
xlSheet.Cells(4, (7 * i) + 11).Value = "S"
xlSheet.Cells(t.ID + 4, ((7 * i) + 5)).Interior.ColorIndex = 37
xlSheet.Cells(t.ID + 4, (7 * i) + 6).Interior.ColorIndex = 37
xlSheet.Cells(t.ID + 4, (7 * i) + 7).Interior.ColorIndex = 37
xlSheet.Cells(t.ID + 4, (7 * i) + 8).Interior.ColorIndex = 37
xlSheet.Cells(t.ID + 4, (7 * i) + 9).Interior.ColorIndex = 37
xlSheet.Cells(t.ID + 4, (7 * i) + 10).Interior.ColorIndex = 37
xlSheet.Cells(t.ID + 4, (7 * i) + 11).Interior.ColorIndex = 37
Next i
Next t
End Sub
最佳答案
有可能,我有一个多年来可以做到这一点的宏。
使用下面的代码。
Sub ExportToExcel()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim proj As Project
Dim t As Task
Dim pj As Project
Dim pjDuration As Integer
Dim i As Integer
Set pj = ActiveProject
Set xlApp = New Excel.Application
xlApp.Visible = True
'AppActivate "Excel"
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.cells(1, 1).Value = "Project Name"
xlSheet.cells(1, 2).Value = pj.Name
xlSheet.cells(2, 1).Value = "Project Title"
xlSheet.cells(2, 2).Value = pj.Title
xlSheet.cells(1, 4).Value = "Project Start"
xlSheet.cells(1, 5).Value = pj.ProjectStart
xlSheet.cells(2, 4).Value = "Project Finish"
xlSheet.cells(2, 5).Value = pj.ProjectFinish
xlSheet.cells(1, 7).Value = "Project Duration"
pjDuration = pj.ProjectFinish - pj.ProjectStart
xlSheet.cells(1, 8).Value = pjDuration & "d"
xlSheet.cells(4, 1).Value = "Task ID"
xlSheet.cells(4, 2).Value = "Task Name"
xlSheet.cells(4, 3).Value = "Task Start"
xlSheet.cells(4, 4).Value = "Task Finish"
' Add day of the week headers for the entire Project's duration
For i = 0 To pjDuration
xlSheet.cells(4, i + 5).Value = pj.ProjectStart + i
xlSheet.cells(4, i + 5).NumberFormat = "[$-409]d-mmm-yy;@"
Next
For Each t In pj.Tasks
xlSheet.cells(t.ID + 4, 1).Value = t.ID
xlSheet.cells(t.ID + 4, 2).Value = t.Name
xlSheet.cells(t.ID + 4, 3).Value = t.Start
xlSheet.cells(t.ID + 4, 3).NumberFormat = "[$-409]d-mmm-yy;@"
xlSheet.cells(t.ID + 4, 4).Value = t.Finish
xlSheet.cells(t.ID + 4, 4).NumberFormat = "[$-409]d-mmm-yy;@"
For i = 5 To pjDuration + 5
'Loop to add day of week headers and color cells to mimic Gantt chart
If t.Start <= xlSheet.cells(4, i) And t.Finish >= xlSheet.cells(4, i) Then
xlSheet.cells(t.ID + 4, i).Interior.ColorIndex = 37
End If
Next i
Next t
关于excel - 使用 VBA 将 MS Project 转换为 Excel 甘特图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37445158/
我有一个 Pandas DataFrame,其中包含流量计开始测量流量的日期和站点退役的日期。我想生成一个以图形方式显示这些日期的图。这是我的 DataFrame 的示例: import pandas
我必须每天生成甘特图。我的想法是使用 R 的 DiagrammeR 包中包含的美人鱼 api。 我的数据将始终具有相同的结构,因此,我创建了一个非常原始的解析器,该解析器包含在可重现的示例中。 我面临
我不知道 Angular js,我正在使用这里的 Angular 甘特图https://github.com/angular-gantt/angular-gantt & 此图表显示日期但不显示日期(S
我正在尝试找出一种在 Highcharts Gantt 依赖路径上添加悬停工具提示的方法;但我不确定最好的方法,因为似乎没有 native 配置属性来与依赖路径和端点交互。 我从在渲染的 .highc
我一直在使用使用 javascript 的 DhtmlxGantt。我希望能够进行一些计算,例如里程碑、进度和天数。我想知道是否可以使用 DhtmlxGantt API java 而不是 javasc
我正在尝试构建一个甘特图,就像在这个 JSFiddle 示例中一样[ http://jsfiddle.net/2xkfm87e/11/ ](我现在已经使用下面的 jlbriggs 输入将这个 fidd
var tasks; d3.json("http://localhost:8080/result", function(error, data) { tasks = data data.f
我是 JFree 的新手。我想知道如何创建数据集,使特定作业的所有操作都具有相同的颜色(例如,O111、O122、O133、O144 具有相同的颜色,机器排列如图 2 所示)。 我尝试使用 TaskS
我想做一个循环,以便将所有数据放入我的图表中。但是,我不知道该怎么做。我试过一些东西,但没有用。我在循环行得到一个 Uncaught SyntaxError: $(".gantt").gantt({
我有 100% 的甘特图高度,但如果甘特图有很多信息,他会创建一个卷轴,或者如果有一些信息,他会创建一个包含信息和非常大空间的大正方形,直到正方形结束。任何想法,请帮助。我想要的是如果有很多信息不创建
我对 Javascript 比较陌生,并且一直在我的网站上使用 JSGantt.js 制作甘特图。 html 页面上所需的唯一代码如下所示: // here's all the html
我正在努力寻找有关如何执行此操作的任何真实文档,基本上我使用 jquery.gantt ( http://taitems.github.io/jQuery.Gantt/ ) 显示数据库中的数据,并且需
我正在寻找一个基于 JS 的资源规划组件,其中我在左侧有可用资源,在右侧有资源负载。 到目前为止,我只找到了一些甘特图实现,它们缺乏添加、移动和编辑功能。我想知道这样的组件是否存在。 最佳答案 我不知
我想在包含“建议播种窗口”和实际播种日期的甘特图上叠加降雨数据(列)。从数据集中,我可以分别创建两者,但不能在一个图表上创建。任何指针都非常感谢。 ## plot Gantt chart with s
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 3 年前。
我知道 Sharepoint 对甘特图有一些支持(任务的甘特 View )。我正在寻找的是提供高级任务关系的方法(FF:完成到完成,FS:完成到开始等)有没有办法提供它或者是否有免费的组件? 最佳答案
向 this example 中的 d3 甘特图添加水平网格线的最佳方式是什么? ?我最初想制作一个轴并使刻度标记为图表的长度(如 this example 中所示),但这会将它们直接放在图表矩形的中
我必须使用 jQuery 将类似甘特图 的工具集成到房间预订解决方案中。甘特图应该是非常互动的,而不是简单地显示数据。它应该响应拖放,它应该在左侧有一个 TreeView 来对任务进行分组,它应该有缩
我正在使用一个数据集,该数据集描述了与一系列公司的契约(Contract)期限。显然,所有契约(Contract)都有开始日期和(最短)期限。然而,某些契约(Contract)可能会延长。这是一个数据
我在 JavaScript 中使用 Highcharts 甘特图。 我想停用表格顶部的标题,这对我来说没有用。截图中的红色矩形: https://files.normanfeltz.fr/files/
我是一名优秀的程序员,十分优秀!